Link to home
Start Free TrialLog in
Avatar of praveen1981
praveen1981Flag for India

asked on

comparing the textbox value with zero using javascript

Hi

I am getting the textbox value which is having "00.00" but while i am comparing i am spliting this value with '.'
and checking with "0"
var fieldValue=document.getelementbyid('t1').value;

if(fieldValue.split('.')[0] == "0" || fieldValue.split('.')[1] == "0")

but now when the user enters more than one zero value my condition is failing  is there any way to handle this

Please suggest
ASKER CERTIFIED SOLUTION
Avatar of Kiran Sonawane
Kiran Sonawane
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
var fieldValue = parseFloat( document.getElementById('t1').value );
if( fieldValue == 0 )

Open in new window

http://www.w3schools.com/jsref/jsref_parseFloat.asp
Avatar of praveen1981

ASKER

It solved