开发者

Is 000,000,000.00 greater than zero?

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 be开发者_开发问答fore 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.


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 )


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜