I am trying to use client-side validation with javascript. I feel like I am on the right track, but for some reason this code is not working.
My page is found at:
Simple Form Validation
All the source is there if you hit view source.
Simple JavaScript Validator
Started by Blue Indian, Sep 16 2010 09:54 AM
4 replies to this topic
#1
Posted 16 September 2010 - 09:54 AM
|
|
|
#2
Posted 16 September 2010 - 10:06 AM
Load this up in Firefox and debug it using an AddOn called Firebug. You're getting an error on line 20 in your .js file that says an object is expected. Also, you can use JSLint to validate your javascript code and quickly identify any errors. One thing I saw is that you're using "=" to evaluate equality instead of "===" which is a no no. If you use the equals operator like this "=" your attempting to assign a value and not evaluate if two values are equal.
If you need any more help let me know.
BTW. this is my 300th post. FTW!
If you need any more help let me know.
BTW. this is my 300th post. FTW!
-CDG10620
Software Developer
Software Developer
#3
Posted 16 September 2010 - 10:13 AM
There are some problems...
- IsNaN should be isNaN (first 'i' must be lowercase)
- innerText is not supported by some browsers. It's better to use innerHTML.
- The age check should only be done if the name is correct or don't change the value of isValid if it was false (actually, if you write a wrong name but a correct age, it will show the last message 'You entered ...')
#4
Posted 21 September 2010 - 03:25 AM
Well it works fine for me :D
#5
Posted 21 September 2010 - 04:48 AM
Yes, I fixed it with the help of the previous suggestions.
Thanks guys!
Thanks guys!


Sign In
Create Account


Back to top









