Characters Only Please

[Total: 0    Average: 0/5]

This script validates form input to be only characters.

Body Code:

Enter 4 non-numbers: <input type=text name=chars>
<input type=button onclick=verify(this.form) value="verify">
function verify(_f)
  var _x=_f.chars.value;

  var _exp1 = new RegExp(/^[a-z]+$/i); /* any non space */
  var _test=_exp1.test(_x);
  if(_x.length!=4)alert("length not correct");
  else if(!_test)alert("found non [a-z] [A-Z] items");
  else alert("this value is okay.");

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *