Created
August 16, 2011 21:37
-
-
Save niczak/1150238 to your computer and use it in GitHub Desktop.
jQuery Form Validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fnValidate() | |
{ | |
var aFields = | |
{"First Name":"sFirst", | |
"Last Name":"sLast", | |
"DRI Affiliation":"sAffil1", | |
"DRI Email":"sEmail_DRI"}; | |
var bValid = true; | |
$.each(aFields, function(key, value) | |
{ | |
// Debug | |
//alert(key+":"+value); | |
var sValue = $("#"+value).val(); | |
if(!sValue.length) | |
{ | |
alert(key+" can not be empty."); | |
bValid = false; | |
} | |
}); | |
return bValid; | |
} | |
function fnSubmit() | |
{ | |
if(fnValidate() === true) { | |
$("#frmEdit").submit(); | |
} | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment