Check letters, numbers and special characters

Are you using IE, Firefox, Chrome, Opera, Safari?

If IE, have you enabled the advanced notification about script errors? I ask because any kind of script failure fails to prevent the form from being submitted.

I normally test in Chrome, but when I use IE to test your page with that setting enabled, I do see an error occur. I’ll investigate further and find out what is causing the problem.

Oh, I see. Okay.

The problem that you’re facing with IE is that IE is dumber than your average browser.
The regular expression needs to use the exec() method to pass the string.

var result = /^[a-z0-9\\.;,:''\\s]{1,100}$/i[color="green"].exec[/color]( theForm.data.value );

So this code allows IE to work properly.


var result = /^[a-z0-9\\.;,:''\\s]{1,100}$/i.exec( theForm.data.value );

Thanks Sir, now this code working. :slight_smile:

I.E. won't execute the regex directly, so [I]exec[/I] must be called...

The regex you're using cannot differentiate between bad input and no input,
which dictates testing to ensure that the string has a length.

<script type='text/javascript'>

function checkForm( theForm )
{
  var result = /^[a-z0-9\\.;,:'\\s]{1,100}$/i.exec( theForm.data.value );  
 
  if( !result )
  {
     alert( theForm.data.value.length ? "Illegal characters entered" : "No legal characters entered");
  }
   
  return !!result; 
}
</script>

Thanks Sir!