Skip to content

Instantly share code, notes, and snippets.

@mitchellhislop
Forked from niczak/gist:1150238
Created August 16, 2011 21:37
Show Gist options
  • Save mitchellhislop/1150240 to your computer and use it in GitHub Desktop.
Save mitchellhislop/1150240 to your computer and use it in GitHub Desktop.
jQuery Form Validation
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