Hi
I have been working on a project and created my forms using an infield label technique with jQuery that placed the title as the label and on focus it disappeared. That works exactly how i wanted it too however it has created a huge problem because the title must be mistaken for a value and the mandatory fields are being ignored and if a user doesn’t input anything into the field the value is coming through in the enquiries as the title.
My question is - how do I validate my form by adding a rule of if the value equals the title to send back an error and prompt the user to enter a correct value?
Here is an example of a form on my site:
The code for the field label is:
$('input[title], textarea[title]').each(function() {
if($(this).val() === '') {
$(this).val($(this).attr('title'));
}
$(this).focus(function() {
if($(this).val() == $(this).attr('title')) {
$(this).val('').addClass('focused');
}
});
$(this).blur(function() {
if($(this).val() === '') {
$(this).val($(this).attr('title')).removeClass('focused');
}
});
});
Any help would be greatly appreciated
Rachel