Jump to content

Help With Text Validating With Ajax


Guest balboa
 Share

Recommended Posts

There are only two statements that set the text value to "". Each one occurs after an if(){} statement. Put an alert statement before each if(){} clause so you can see for yourself what the values are that you are testing. They might not be what you think.Hint 1: an <input> element does not have a .length property.Hint 2: it is not enough to test ajax.readyState == 4 . You should also test ajax.status == 200 . Other status values are possible when readyState==4. 4 simply means that a response was received, even if the response is an error message, like Error 500 or Error 203. So, for example, if your server script contains an parsing error or runtime error, ajax.responseText will not equal "fel" (even if the input would fail validation) and your script will fall into the else(){} clause.Hint 3: an inline event handler does not need "javascript:" in it. That construction is normally used when you want to include executable statements in the href property of an <a> element. (But this is not causing your problem.)

Edited by Deirdre's Dad
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...