<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="js/validationengine/css/validationEngine.jquery.css" rel="stylesheet" type="text/css">
<style type="text/css">
body{color:#003c68;font-family:font-family:Verdana,Helvetica,Arial,Sans-Serif;font-size:18px;}
input{ width:160px;}
select{ width:160px;}
</style>
<title>Test validation</title>
</head>
<body>
<br>
<br><form id="form_1">
<div id="testdiv">
<div id="step_1" class="step">
<input type="text" name="testname" id="testname" value="" class="validate[required]">
<br>
<br>
<select name="test" class="test validate[required] select" id="test">
<option value="">please select</option>
<option value="1">first option</option>
</select>
<br>
<button class="next">Next</button>
</div>
<div id="step_2" class="step" style="display:none;">
This is the second step
<br>
<input type="text" name="testname2" id="testname2" value="" class="validate[required]">
<br>
<br>
<button class="next">Next</button>
</div>
<div id="step_3" class="step" style="display:none;">
This is the third step
<br>
<button class="send">Submit</button>
</div>
</div>
</form>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/validationengine/js/jquery.validationEngine.js"></script>
<script type="text/javascript" src="js/validationengine/js/jquery.validationEngine-en.js"></script>
<script type="text/javascript">
$(function() {
$('#testdiv').on("click", ".next", function(event) {
var current = $('div.step:visible');
alert(current.attr('id'));
var next = current.next();
$("#form_1").validationEngine({
onValidationComplete: function(form, status){
alert(status);
if (status == true) {
current.hide();
next.show();
}else { }
}}
);
});
$('#testdiv').on("click", ".send", function(event) {
$("#form_1").validationEngine({
onValidationComplete: function(form, status){
if (status == true) {
alert('The form is submitted')
//code to submit the form via ajax
}else { }
}}
);
});
}
);
</script>
</body>
</html>
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY