I have the following script which validates pages using jquery.validate.js through a quiz and works perfectly. Im looking to have the error message for required fields to be placed into a div called errormessage. jQuery validate usually returns a message "this field is required".
Here is the script
<script type="text/javascript">
var curPage=1;
function NextPage() {
if (curPage < <?= $num; ?>) {
var group = "#page_" + curPage.toString();
var isValid =true;
$(group).find(':input').each(function (i, item) {
if (!$(item).valid())
isValid = false;
});
if( !isValid){ alert("PLEASE MAKE A SELECTION"); }
else{
$("#page_" + curPage.toString()).hide(); //hide current page div
curPage++; //increment curpage
$("#page_" + curPage.toString()).show(); //show new current page div
}
}
}
function PrevPage() {
if (curPage > 1) {
$("#page_" + curPage.toString()).hide(); //show new current page div
curPage--; //increment curpage
$("#page_" + curPage.toString()).show(); //hide current page div
}
}
function InitializePage() {
$(".wizardPage").hide();
$("#page_" + curPage.toString()).show();
$("#surveyForm").validate({onsubmit: false});
}
$(document).ready(InitializePage
);
</script>
<label>tag that hasclass="error". Do you want to disable that functionality and list all error messages inside another div element?