Skip to content

Instantly share code, notes, and snippets.

@veryrobert
Created April 25, 2014 10:19
Show Gist options
  • Save veryrobert/11284628 to your computer and use it in GitHub Desktop.
Save veryrobert/11284628 to your computer and use it in GitHub Desktop.
Form Validation for Errors
// <form id="myForm" name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post" class="form" novalidate>
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
$('input.required').addClass('warning');
$('input.required').after('<p class="warning four-eight">Form field entered incorrectly please try again</p>');
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment