HTML5 form validation pattern alphanumeric with spaces?

后端 未结 7 2116
借酒劲吻你
借酒劲吻你 2020-12-08 00:10

I have the following input tag in my html5 form:

7条回答
  •  萌比男神i
    2020-12-08 00:44

    Use Like below format code

    $('#title').keypress(function(event){
        //get envent value       
        var inputValue = event.which;
        // check whitespaces only.
        if(inputValue == 32){
            return true;    
        }
         // check number only.
        if(inputValue == 48 || inputValue == 49 || inputValue == 50 || inputValue == 51 || inputValue == 52 || inputValue == 53 ||  inputValue ==  54 ||  inputValue == 55 || inputValue == 56 || inputValue == 57){
            return true;
        }
        // check special char.
        if(!(inputValue >= 65 && inputValue <= 120) && (inputValue != 32 && inputValue != 0)) { 
            event.preventDefault(); 
        }
    })
    

提交回复
热议问题