![]() |
data validation
How to do data validation while submitting form?
|
You validate your data with javascript, before sending them to the server.
Example: And in javascript: function validate_contact(){ var name=jQuery.trim($('#name').val()); var email=jQuery.trim($('#email').val()); var comments=jQuery.trim($('#comments').val()); if (name=='' || name.length<3) {alert ('Please enter your name');return false;} if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)==false) {alert('Please enter valid email address');return false;} if (comments.length<1) {alert('Please enter your comments');return false;} } |
All times are GMT -7. The time now is 07:39 PM. |
Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.