then the input key will not work. However, I can us...">

How to enable key input?

So, two questions: if I use <input type="button" onclick="validate()"> then the input key will not work. However, I can use type="submit" , but how can I call validate() ?

+4
source share
1 answer

You can have a validate form in submit, which is better anyway:

 <form ... onsubmit="return validate()"> <input type="submit" /> </form> 

You can return false from your validation function to prevent the form from submitting. The form will be checked whether it is submitted via a return key or by pressing a button.

+3
source

Source: https://habr.com/ru/post/1306639/


All Articles