This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes validating user Input using java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "validating user Input using java script" Watch "validating user Input using java script" New topic
Author

validating user Input using java script

amrut sabade
Ranch Hand

Joined: Aug 16, 2010
Posts: 90
Hi everyone ... i have one registration form which contains text boxfor email and i have to validate wheather the entered email id is valid or not i ma using following script to validate on onblur event.. but its giving me error that object expected... please help ...whats is going wrong with it...
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32301
    
213

Which line gives that error?

Also, can you try adding alert(inputField.value) to show that value isn't null. If it is null, show how you are calling the function.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
amrut sabade
Ranch Hand

Joined: Aug 16, 2010
Posts: 90
i am calling the function as onblur="return validateEmail()" and this line is giving error...
is it correct tocall function as this
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 299
amrut sabade wrote:i am calling the function as onblur="return validateEmail()" and this line is giving error...
is it correct tocall function as this


No, it is not correct, as in the first line you are doing inputField.value.length, if you call the function without the inputField argument this is undefined and it will throw an error in the very first line, try onblur="return validateEmail(this)" (in case you want to check the field where you are setting the onblur)

Also install the firebug plugin to help you create and debug javascript part of your application http://getfirebug.com/ and check the very useful screencasts here http://getfirebug.com/screencasts
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: validating user Input using java script
 
jQuery in Action, 3rd edition