خرید بک لینک
I'm trying to amend some validation on our webform for the users name.

this is what I have so far - that works:
(the code below validates the name field to have 2-18 characters)

Code:

var divWarning = document.getElementById('divWarning');
if (!divWarning)
  {alert('Unable to find warning control');return;}

// Validates the Name is between 2 and 18 characters
var txtName2 = document.getElementById('txtLASTNAME');
if (!txtName2)
  {alert('Unable to find name control');}
else
  {
    if (txtName2.value == '' || txtName2.value == sNameDef)
      {divWarning.ierHTML='A name is required to start chatting'; divWarning.style.display='block'; txtName2.focus(); txtName2.className='inputerr'; return;}
    else
    {
      if (txtName2.value.length < 2 || txtName2.value.length > 18 )
          {divWarning.ierHTML='Your last name must be between 2 and 18 letters'; divWarning.style.display='block'; txtName2.focus(); txtName2.className='inputerr'; return;}
  }
}

however, it accepts all characters. I would like to limit this to just letters.
I was thinking of something like:

Code:

  if  var letters = /^[A-Za-z]+$/; 
        (txtName2.value.match(letters))

But no matter where I insert this code above - it never results in the form being submitted successfully - it always fails!

any ideas?

برچسب: نویسنده: آیلین رضوانی تاريخ: چهارشنبه 20 دی 1396 ساعت: 7:09

صفحه بندی