Level 75
Use type tel and you can also use pattern attribute.
<input type="tel" name="phone">
Docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel
I want to validate this input for phone.Up to 10 digit only and no text allowed only number digit
<input type="text" name="phone" onkeypress='validate(event)'>
Although no text allowed worked but how to validate upto maximun 10 digit
<script>
function validate(evt) {
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode( key );
var regex = /[0-9]|\./;
if( !regex.test(key) ) {
if(!regex.test(key) >=10 && !regex.test(key)<=10){
theEvent.returnValue = false;
if(theEvent.preventDefault) theEvent.preventDefault();
}
}
}
</script>
Please or to participate in this conversation.