Java Script Validation for Text Field:
First we need to declare the Regular Expression for the Alphabetic validation like this,
var alphabetic = /^[a-zA-Z ]+$/;
Then we need to store our field value as a variable like this,
var fname=$('#edit-firstName').val();
Now we need to check whether the entered content is alphabetical or not,It will accept only alphabets..
if((fname == '') || (!alphabetic.test(fname))){
errorCount = 1;
error+= "You must supply a alphabetic value for the 'FullName' field of this form.";
}
errorCount = 1;
error+= "You must supply a alphabetic value for the 'FullName' field of this form.";
}
No comments:
Post a Comment