I'm using jquery.validate plugin and facing the following situation:
<form id="myForm" ....>
<input type="text" id="value1"/>
<!-- Here is some code rendered from the partial -->
<script type="text/javascript">
$(document).ready(function() {
var validator = $('#myForm').validate({
rules: {
value_from_partial: {
required: true
}
},
messages: {
value_from_partial: {
required: "Enter your firstname"
}
},
submitHandler: function() {
alert("submitted!");
}
});
});
</script>
<input type="text" id="value_from_partial"/>
<!-- End of code rendered from the partial -->
</form>
<script type="text/javascript">
$(document).ready(function() {
var validator = $('#myForm').validate({
rules: {
value1: {
required: true
}
},
messages: {
value1: {
required: "Enter your firstname"
}
},
submitHandler: function() {
alert("submitted!");
}
});
});
</script>
Validation added in the partial doesn't work. When I remove .validate from the main html, then validation in the partial works. It seems that jquery.validate doesn't allow that there are two .validate calls on the same form. On the other hand, I can not call "add" rules for validator, since I want my validation code to come from the partial itself (which is actually a plugin). Is there any way to include my validation logic together with the partial, and to use jqury.validate instead of manual validation. Is there any other validation framework that can allow this? Thanks!