Enter button MVC3, triggered by the Enter button

I have an ASP.NET MVC 3 C # .NET web application and I want the Enter button to call a specific Save button in my form. How can I do it?

+4
source share
1 answer

I would use JavaScript for this. Handle onkeypress even in the form of . For instance:

 <form onkeypress="yourKeyPressFunction(event)"> ... </form> 

Then your yourKeyPressFunction() will look something like this:

 function yourKeyPressFunction(e) { if (e.keyCode == 13) { // submit or do what you'd like when you hit enter } // ... so on and so forth } 
+1
source

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


All Articles