| Author |
Conditional operators in javaScript
|
Anant Rao
Ranch Hand
Joined: Nov 12, 2004
Posts: 126
|
|
Hi, I am using struts and javascript for validation I want to check two fiels with <= condition. When save button is clicked it should display a alert msg. Below is the code: if(document.form.TargetNumber.value <=document.form.SubmissionNumber.value){ alert("wrong number entered"); return false; } But the application behaves weird..at times it displays msg and yet times it does not. As per my oberservation if single digits are entered it works fine but when double digits are entered it does not throw the alert msg. can any one help me out whats problem with code or suggest any alternative Happy New Year Infyniti.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56207
|
|
|
You do realize that that code is doing string comparisons?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
To add what Bear is saying you need to use parseInt or parseFloat on the values to make them numeric. Eric
|
 |
Anant Rao
Ranch Hand
Joined: Nov 12, 2004
Posts: 126
|
|
Thanks that helped me out. Infyniti
|
 |
 |
|
|
subject: Conditional operators in javaScript
|
|
|