function doCustomValidation() { var email = $("#email").val(); var email_confirm = $("#email_confirm").val(); if (email != email_confirm) { alert("Email address is not consistent"); return false; } $.post("./saveInfo_en.jsp", $("#myform").serialize(), function(data, textStatus) { if ("success" == jQuery.trim(textStatus)) { data = $.trim(data); if ("" != data) { var msg = data.split(","); alert(msg[0]); if (msg.length > 1) { if (msg[1] == "true") { window.location.reload(); } else { $("#" + msg[1]).focus(); } } } else { alert("Please try again, server is busy."); } } else { alert("Please try again, server is busy."); } }); return false; } $(function() { // init button group $("#ser_type .btn").click(function() { $("#ser_type .btn").removeClass("active"); $(this).addClass("active"); $("[name=ser_type]").val($(this).html()); }); $("#call .btn").click(function() { $("#call .btn").removeClass("active"); $(this).addClass("active"); $("[name=call]").val($(this).html()); }); $("#callBackDate .btn").click(function() { $("#callBackDate .btn").removeClass("active"); $(this).addClass("active"); $("[name=callBackDate]").val($(this).val()); }); $("#callBackTime .btn").click(function() { $("#callBackTime .btn").removeClass("active"); $(this).addClass("active"); $("[name=callBackTime]").val($(this).html()); }); // form valid var frmvalidator = new Validator("myform"); frmvalidator.addValidation("ser_type", "req", "Please select Service Type"); /* * frmvalidator.addValidation("acct_no", "req", "Please enter Account * Number"); frmvalidator.addValidation("acct_no", "regexp=\\d{8}-\\d{3}", * "Please enter valid Account Number"); */ frmvalidator.addValidation("call", "req", "Please select Title"); frmvalidator.addValidation("name", "req", "Please enter Name"); frmvalidator.addValidation("email", "req", "Please enter Email"); frmvalidator.addValidation("email_confirm", "maxlen=50", "Please enter a correct email address"); frmvalidator.addValidation("email_confirm", "email_confirm", "Please enter a correct email address"); frmvalidator.addValidation("email_confirm", "req", "Please enter Email"); frmvalidator.addValidation("email", "maxlen=50", "Please enter a correct email address"); frmvalidator.addValidation("email", "email", "Please enter a correct email address"); frmvalidator.addValidation("mobile", "req", "Please enter Contact Mobile Number"); frmvalidator.addValidation("mobile", "minlen=8", "Please enter a correct contact mobile number"); frmvalidator.addValidation("mobile", "maxlen=8", "Please enter a correct contact mobile number"); frmvalidator.addValidation("mobile", "numeric", "Please enter a correct contact mobile number"); frmvalidator.addValidation("mobile", "first_char", "Please enter a correct contact mobile number"); frmvalidator.addValidation("callBackDate", "req", "Please select Preferred contact date"); frmvalidator.addValidation("callBackTime", "req", "Please select Preferred Timeslot"); frmvalidator .addValidation( "tAndC", "boxcheck", "Please accept the terms and conditions as contained in Privacy Policy and Personal Information Collection Statement"); frmvalidator.setAddnlValidationFunction(doCustomValidation); });