Jquery how to check if a input has a number higher then 99

后端 未结 8 1268
离开以前
离开以前 2021-01-06 05:08

Was wanting to know how to check using jquery if a input contains a number higher then 99

8条回答
  •  [愿得一人]
    2021-01-06 05:43

    try this:

    if(parseInt($("selector").val()) > 99) {
        /*if it is*/
    }
    

    or if you are checking it on change:

    $("selector").change(function(){
         if(parseInt(this.value) > 99){
            /*if it is*/
         } 
    })
    

    Edit as said in the below comments, it might be better to use parseFloat instead of parseInt to compare the numbers

提交回复
热议问题