We help IT Professionals succeed at work.

comparing the textbox value with zero using javascript

praveen1981
praveen1981 asked
on
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
Comment
Watch Question

Project Lead
CERTIFIED EXPERT
Top Expert 2011
Commented:
Check like this

if(parseInt(fieldValue.split('.')[0]) == 0 || parseInt(fieldValue.split('.')[1]) == 0)
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
var fieldValue = parseFloat( document.getElementById('t1').value );
if( fieldValue == 0 )

Open in new window

http://www.w3schools.com/jsref/jsref_parseFloat.asp

Author

Commented:
It solved

Explore More ContentExplore courses, solutions, and other research materials related to this topic.