How to do form validation in javascript - Web Development
116 Views

How to do form validation in javascript

The validation part of javascript is very easy

This below code block is doing validation

if(name == “”) {
printError(“nameError”, “Please enter your name”);
} else {
var regex = /^[a-zA-Z\s]+$/;
if(regex.test(name) === false) {
printError(“nameError”, “Please enter a valid name”);
} else {
printError(“nameError”, “”);
nameError = false;
}
}

If you run this code in your broswer

 

 

 

 

Candidate Info Form

 
 
 
 
 

 

See PHP and JQUERY Tutorials

 

http://www.goolik.com/pdo-registration-in-php/
http://www.goolik.com/move-object-using-javascript/
http://www.goolik.com/how-to-use-accordion-in-jquery/
http://www.goolik.com/add-remove-class-using-jquery-ui/

2 Replies to “How to do form validation in javascript”

Leave a Reply

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