Validate Letters n Spaces

[Total: 0    Average: 0/5]

This determines if the input contains the letters or spaces only.

Body Code:

this will validate the input contains only letters a-z, A-Z or spaces and nothing else.

<form name=f1>
<input type=text name=t1 value="abc def">
<input type=button value="click" onclick="doIt()">
</form>
<script>
function doIt()
{
  var _f=document.f1;
  var _exp4 = new RegExp(/^[a-z ]+$/i);
  var _test4 =_exp4.test(_f.t1.value);

if(!_test4){alert("nope");}

}
</script>

Times Viewed: 2

Leave a Reply

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