Validating text fields in javascript


Your doctype is setting the language you’re using and code that’s valid under one doctype may not be valid using another.

For example This is a sentence validates under html 4.01 transitional or html5 where the closing tag is not required, but not under xhtml 1.0 transitional where the closing tag is required.

If you click the links above it’ll look like they go to the same page, but I assure you they’re different.

Click the More Options link to see on each page to see.

Note that I also left off the period after “This is a sentence” above, which violates the rules of grammar, but likely doesn’t cause any problems in communication.