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

后端 未结 8 1183
离开以前
离开以前 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:42
    if ($("#myfield").val() > 99) {
    
    }
    
    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题