jQuery input mask

后端 未结 2 1461
说谎
说谎 2021-01-15 08:28

Hey, I am new to jQuery , I want to check onblur on input box this format cda 123 . mean first 3 characters space and 3 integers. Usually I see that code is written on Input

2条回答
  •  情话喂你
    2021-01-15 09:20

    You can use try using regular expressions.

    if($('input').val().match(/.{3} \d{3}$/)){
            alert('valid');
        }
        else{
            alert('invalid');
        }
    

    Check out a sample demo for your case here

    http://jsfiddle.net/ryan_s/WYzhR/1/

提交回复
热议问题