Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5153a418cd
Fetching contributors…

Cannot retrieve contributors at this time

94 lines (90 sloc) 4.006 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>JQuery Validation Engine</title>
<link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css"/>
<link rel="stylesheet" href="../css/template.css" type="text/css"/>
<script src="../js/jquery-1.6.min.js" type="text/javascript">
</script>
<script src="../js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8">
</script>
<script src="../js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<script>
// This method is called right before the ajax form validation request
// it is typically used to setup some visuals ("Please wait...");
// you may return a false to stop the request
function beforeCall(form, options){
if (console)
console.log("Right before the AJAX form validation call");
return true;
}
// Called once the server replies to the ajax form validation request
function ajaxValidationCallback(status, form, json, options){
if (console)
console.log(status);
if (status === true) {
alert("the form is valid!");
// uncomment these lines to submit the form to form.action
// form.validationEngine('detach');
// form.submit();
// or you may use AJAX again to submit the data
}
}
jQuery(document).ready(function(){
jQuery("#formID").validationEngine({
ajaxFormValidation: true,
onAjaxFormComplete: ajaxValidationCallback,
onBeforeAjaxFormValidation: beforeCall
});
});
</script>
</head>
<body>
<p>
<a href="#" onclick="alert(jQuery('#formID').validationEngine({evaluate:true}))">Return true or false without binding anything</a>
| <a href="#" onclick="jQuery.validationEngine.buildPrompt('#formID','This is an example','error')">Build a prompt on a div</a>
| <a href="#" onclick="jQuery.validationEngine.loadValidation('#date')">Load validation date</a>
| <a href="#" onclick="jQuery.validationEngine.closePrompt('.formError',true)">Close all prompt</a>
| <a href="../index.html" onclick="">Back to index</a>
</p>
<p style="color:red; text-align:center">Please run this demo from a WebServer (ie. http://localhost:9173/demoAjax.html after running the demo server), it will fail if you double click demoAjax.html -> It needs a server.
</p>
<p>
This demonstrations shows the use of Ajax <b>form</b>
and <b>field</b>
validations.
<br/>
The form validation implements callback hooks, so please check the javascript console
</p>
<form id="formID" class="formular" method="post" action="ajaxSubmitForm" style="width:600px">
<fieldset>
<legend>
Ajax validation
</legend>
<label>
<span>Desired username (ajax validation, only <b>karnius</b> is available) : </span>
<input value="karnius" class="validate[required,custom[onlyLetterNumber],maxSize[20],ajax[ajaxUserCall]] text-input" type="text" name="user" id="user" />
<p>
validate[required,custom[noSpecialCaracters],maxSize[20],ajax[ajaxUserCall]]
</p>
</label>
<label>
<span>First name (ajax validation, only <b>duncan</b> is available): </span>
<input value="olivier" class="validate[custom[onlyLetterSp],maxSize[100],ajax[ajaxNameCall]] text-input" type="text" name="firstname" id="firstname" />
<p>
validate[custom[onlyLetterSp],length[0,100],ajax[ajaxNameCall]]
</p>
</label>
<label>
<span>Email address : </span>
<input value="someone1@here.com" class="validate[required,custom[email]] text-input" type="text" name="email" id="email" />
<p>
validate[required,custom[email]]
</p>
</label>
</fieldset>
<input class="submit" type="submit" value="Validate &amp; Send the form!"/><hr/>
</form>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.