Trying to use the jQuery validation engine for 1 text field. For some reason It's not doing anything. I don't any errors to work off. If anyone see's something missing or out of place, I'd appreciate it.`
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script src='jquery-1.11.0.min.js'></script>
<script src="jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="jQuery-Validation-Engine-master/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="jQuery-Validation-Engine-master/css/validationEngine.jquery.css" type="text/css"/>
</head>
<body>
<form id="formID" name="myForm" method="post" action="submit.action">
<input class="validate[required]" type="text" id="agree" name="agree"/>
<button type="button" value="Save" id="Save" onclick="clicked();">Submit Survey</button>
</form>
<script type="text/javascript">
function clicked() {
if (confirm('Are you sure you want to submit?')) {
$("#form.id").validationEngine();
} else {
return false;
}
}
</script>
</body>
</html>`
Trying to use the jQuery validation engine for 1 text field. For some reason It's not doing anything. I don't any errors to work off. If anyone see's something missing or out of place, I'd appreciate it.`
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script src='jquery-1.11.0.min.js'></script>
<script src="jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="jQuery-Validation-Engine-master/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="jQuery-Validation-Engine-master/css/validationEngine.jquery.css" type="text/css"/>
</head>
<body>
<form id="formID" name="myForm" method="post" action="submit.action">
<input class="validate[required]" type="text" id="agree" name="agree"/>
<button type="button" value="Save" id="Save" onclick="clicked();">Submit Survey</button>
</form>
<script type="text/javascript">
function clicked() {
if (confirm('Are you sure you want to submit?')) {
$("#form.id").validationEngine();
} else {
return false;
}
}
</script>
</body>
</html>`
Share
Improve this question
asked Nov 15, 2013 at 14:49
user1user1
3572 gold badges13 silver badges22 bronze badges
1
- if someone is able to recreate my code on their machine that might be helpful as I'm wondering if there is something else wrong other than syntax. – user1 Commented Nov 15, 2013 at 15:02
2 Answers
Reset to default 4You should initialize validationEngine like so and not in a onclick function:
$(document).ready(function(){
$("#formID").validationEngine();
});
Your selector is wrong
change:
$("#form.id").validationEngine();
$("#form.id")
--> refers to element with id form
and class id
to:
$("#formID").validationEngine();
Read # id selector