views:

264

answers:

2

I have an input mask on my text box like

        000,000,000.00

I have the following jQuery code to check the value of text box before submitting data.

    var txt_box = $('#txt_box').attr('value');

     if(txt_box <= 0 )

But now even if I didn't input any data, the box remains empty with only the input mask, data is submitting.

+2  A: 

You use <= instead < Anyway, you should parse value to number too.

Rin
+9  A: 

First: Separating floating points with a dot notation is required.

Second: You are checking for equal or less not just less than.

Third: Use parseInt() or parseFloat() to convert that input string into a Number.

Example:

var txt_box = $('#txt_box').attr('value').replace(/,/g, ".");
    if(parseFloat(txt_box) <= 0 )
jAndy