Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   Javascript (http://siteownersforums.com/forumdisplay.php?f=24)
-   -   data validation (http://siteownersforums.com/showthread.php?t=144880)

johnstyle 09-01-2014 02:16 AM

data validation
 
How to do data validation while submitting form?

george.web13 09-03-2014 12:18 AM

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.