Hi,
I'm trying to check whether val() has a specific value or not inside a form, if so deleting the contents / preventing the form being submitted depending on if both fields are filled in (stringOne and stringTwo). There's a default text for each input field, the first being "Namn, telefonnr, sökord" and the second "Område, plats, ort". If a user only fills in the first field the second must be cleared before the form string is passed on and vice versa. Like so -
// "This" refers to the form's submit button
if (($(this).siblings('input.stringOne').val("Namn, telefonnr, sökord")) && ($(this).siblings('input.stringTwo').val("Område, plats, ort"))) {
return false; // If nothing's filled in, then do not submit
} else {
// If either field is not filled in, clear it
if ($(this).siblings('input.stringOne').val("Namn, telefonnr, sökord")) {
$(this).siblings('input.stringOne').val() == '';
}
if ($(this).siblings('input.stringTwo').val("Område, plats, ort")) {
$(this).siblings('input.stringTwo').val() == '';
}
}
jQuery version 1.2.6.