This article illustrates the solution to the problem of submitting the return form of JS cursor positioning text box. Share to everyone for your reference. The specific analysis is as follows:
When the cursor is positioned at the back of the text box in the secondary lookup, the page appears with the JSON string returned by the method.
Reason: When there are only one single-line text input field in a form, the user agent should accept Enter into that field as a re Quest to submit the form.
When there is only one input type= "text" in the form, when the user presses ENTER, the form is submitted.
Solution: The input text onkeydown event to do processing, prohibit carriage return operation.
Specific code:
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19-20 |
<p> <input class= "text text-1" type= "text" name= "name" id= "Notassociatename" value= "" onkeydown= "Enter_down ( event); " /> </p> function Enter_down (event) {if (event.keycode==13) {Stopdefault (event)}} function Stopdefault (e) {//AS If the event object is provided, then this is a non IE browser if (e && e.preventdefault) {//block default browser action E.preventdefault ();} else {//ie prevents the default action of the function in the way Window.event.returnValue = false; return false; } |
I hope this article will help you with your JavaScript programming.