I have a site with a formular containing several input fields. In all of these input fiedls I have the placeholder attribut containing some description. But as we all know the placeholder attribut doesn't work in IE, so I'm also using jQuery Placeholder Enhanced to make the placeholders show up in IE. This works.
But at the same time I'm using jQuery validate to validate my form. When I press the submit button and the validation fails, all og the placeholders are gone in IE.
My validation looks like this:
$(".myForm").validate({
submitHandler: function (form) {
$.post("/handlers/CustomHandler.ashx", $(".myForm").serialize(),
function (data) {
if (data.result.type == "message") {
$(".myForm").parent().html(data.result.data);
}
else if (data.result.type == "redirect") {
location.href = data.result.data;
}
}
);
}
});
I've tried using the invalidHandler option and firing the placeholderEnhanced()-function again like this:
$(".myForm").validate({
submitHandler: function (form) {
$.post("/handlers/CustomHandler.ashx", $(".myForm").serialize(),
function (data) {
if (data.result.type == "message") {
$(".myForm").parent().html(data.result.data);
}
else if (data.result.type == "redirect") {
location.href = data.result.data;
}
}
);
},
invalidHandler: function () {
if (!Modernizr.input.placeholder) {
$('input[placeholder], textarea[placeholder]').placeholderEnhanced();
}
}
});
But unfortanetly it doesn't work. If i copy paste this line:
$('input[placeholder], textarea[placeholder]').placeholderEnhanced();
into my console in IE and firing it after the validation has found some errors, the placeholders are shown again. I've also tried putting in an alert("There was an error in the form"); inside the if-sentence and this is shown when pressing the submit button in the form.
Anyone have some clues to what could be wrong, and how I can make the placeholders not dissapearing in IE after pressing the Submit-button and the validation is not valid.
Thanks in advance!
/Kim