I'm validating some input (type="text"
) boxes with JavaScript (jQuery).
They are on a $('').dialog()
box wich appears when you click on a button.
When I show the dialog the first time everything works great with my verification Code:
function verifyContactForm() {
formValid = true;
txtSubject = $('#txtSubject');
txtRoom = $('#txtRoom');
txtMessage = $('#txtMessage');
if (txtSubject.val() == "") {
formValid = false;
txtSubject.css('border-color', 'red');
}
else
txtSubject.css('border-color', 'lightgray');
if (txtRoom.val() == "") {
formValid = false;
txtRoom.css('border-color', 'red');
}
else
txtRoom.css('border-color', 'lightgray');
if (txtMessage.val() == "") {
formValid = false;
txtMessage.css('border-color', 'red');
}
else
txtMessage.css('border-color', 'lightgray');
return formValid;
}
After the user ended the dialog and everything is valid it sends the data to the server using a ajax call.
Now when the user opens the dialog a second time, without reloading the page, in my text elements the old text is still present. The text isn't shown in the input boxes, but when I select the text with .val()
it still has the old text in it.
Does anybody know why this is like that?
I think it has something to do with caching, but I'm not sure so I'm asking this question.