This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes less than < not wokring in js when compare the value and defaultValue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "less than < not wokring in js when compare the value and defaultValue" Watch "less than < not wokring in js when compare the value and defaultValue" New topic
Author

less than < not wokring in js when compare the value and defaultValue

Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 88
Hi,

I have an issue while check the following condition in java script,



less than < not wokring in js when compare the value and defaultValue?

Regards,
Ganesan
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

You don't have any element with an id of one, what are you expecting your calls to getElementById('one') to return?


Read my books: Hello! HTML5 & CSS3 | HTML5 in Action | Read my blog
Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 88
i have assigned default value as 10.
now i am changing value to 5.
then i clicks the button , it calls the function check().

5 < 10

then the if condition must be execute.
but it not so..



i suspecting the defaultValue return type.

Regards,
Ganesan
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4377
    
    8

As Rob said: there is no element with ID "one". document.getElementById('one') will return null. Therefore document.getElementById('one').value will be an error.

"name" and "id" are not the same attribute.
Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 88
Please assume i am having id in my text field tag.



still my problem is persist.

i want have below alert message when enter the 5, assume default valus is 10,


but am not getting tha above alert message
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

Because you're comparing strings, and the string "10" is alphabetically before the string "5". Try:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: less than < not wokring in js when compare the value and defaultValue