I am trying to check whether val () has a specific value or not inside the form, if it is deleting the contents / preventing the form from being submitted depending on whether both fields (stringOne and stringTwo) are filled. There is default text for each input field, the first of which is Namn, telefonnr, sökord and the second Område, plats, ort. If the user fills in only the first field, the second should be cleared before submitting the form line and vice versa. Also -
if (($(this).siblings('input.stringOne').val("Namn, telefonnr, sökord")) && ($(this).siblings('input.stringTwo').val("Område, plats, ort"))) {
return false;
} else {
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.
source
share