简体   繁体   中英

not allow typing in a text field html, can use JavaScript or any function of html

I have a text field html and it has a datepicker. It not allow typing characters but numbers allow. I need that it not allow numbers.

This one function would do what you want :

Javascript:

document.getElementById("date").onkeyup=function(){
   return false;
}

And here is HTML :

<input id="date" type="date">

See this JS Fiddle Demo . Hope this helps.

您可以使用 Onchange 事件,然后检查输入是否为数字http://www.w3schools.com/jsref/event_onchange.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM