This is for a popup window to occur (link: http://ift.tt/1ACorSz). The validation seems to be completely ignored, and the console leaves me without an error. This code is actually crafted based on the 'jquery.validate.js' example "errors within an element" (within the download file from http://ift.tt/15JYAzL).
HTML:
<form action=
"http://ift.tt/1BDenhM"
class="myForm" id="myForm" method="get" name="myForm"
target="slide_form">
<div id="\'tmg_lock_in\'"></div>
<table align="center" cellpadding="2" cellspacing="2">
<tbody>
<tr style="">
<td align="left"><label>
Name</label><input id="Full_Name" name=
"Full_Name" type="text"></td>
</tr>
<tr style="">
<td align="left"><label>
Email</label><input id="Email" name="Email" type="text"></td>
</tr>
<tr style="">
<td align="left"><label>
Phone</label><input id="Phone" name="Phone" type="text"></td>
</tr>
<tr style="">
<td align="center" colspan="2"><input id=
"submit" name="submit" style=
"outline:none;border:none;font-family:sans-serif;background:rgb(174,55,36);border-radius:12px;-webkit-border-radius:12px;color: #FFFFFF;cursor: pointer;font-size: 16px;font-style: normal;font-weight: bold;padding: 14px;text-align: center;border-bottom:5px solid rgb(147,36,12);padding-bottom: 10px;"
type="submit" value=
"Get Bonus Cash Now"><input name="page" type=
"hidden" value="External Slide"><input name=
"Vehicle_Type" type="hidden" value=
""><input name="tmg_year" type="hidden" value=
""><input name="tmg_make" type="hidden" value=
""><input name="tmg_model" type="hidden" value=
""><input name="tmg_trim" type="hidden" value=
""><input name="tmg_offer" type="hidden" value=
"0"><input name="tmg_stock" type="hidden"
value=""><input name="tmg_vin" type="hidden"
value=""><input name="tmg_price" type="hidden"
value=""><input name="request_type" type=
"hidden" value=""></td>
</tr>
</tbody>
</table>
</form>
JS:
include('http://ift.tt/12QT6l7',
function() {
var imported = document.createElement('script');
imported.src =
'http://ift.tt/1ACopub';
document.head.appendChild(imported);
$.getScript(
'http://ift.tt/1ACopub',
function() {
$.validator.setDefaults({
submitHandler: function() {
alert("submitted!");
}
});
$().ready(function() {
// validate the form when it is submitted
var validator = $("#myForm").validate({
errorPlacement: function(error,
element) {
// Append error within linked label
$(element).closest(
"form").find(
"label[for='" +
element.attr(
"id") +
"']").append(
error);
},
errorElement: "span",
rules: {
Full_Name: {
required: true,
},
Email: {
required: true,
email: true,
},
Phone: {
required: true,
}
},
messages: {
Full_Name: {
required: " (required)",
minlength: " (must be at least 3 characters)"
},
Email: {
required: " (required)",
minlength: " (must be between 5 and 12 characters)",
maxlength: " (must be between 5 and 12 characters)"
},
Phone: {
required: " (required)",
minlength: " (must be between 5 and 12 characters)",
maxlength: " (must be between 5 and 12 characters)"
}
}
});
$(".cancel").click(function() {
validator.resetForm();
});
});
});
});
Thank you
Aucun commentaire:
Enregistrer un commentaire