How to implement the automatic submit form _jsp programming by pressing ENTER in JSP

Source: Internet
Author: User

In order to save a lot of time hope that you can press ENTER to submit the form, to control these behaviors, you can use JS to achieve the requirements.

The code is as follows:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <%@ include file=". /.. /common/include_tag.jsp "%> <%@ include file=". /.. /common/page_var.jsp "%> <! DOCTYPE html>  

Solution:

Put the form form in a div and listen to the DIV for the event $ ("#id"). KeyDown (function () {});

#* #监听回车事件

Document.onkeydown=function () {

if (event.keycode==13) {

//is here to submit your form

$ (' #ff_login '). Submit ()
;

#* #页面编写js脚本进行监听 ...

#* #js监听enter事件 #*#

Put the form form in a div and listen to the DIV for the event $ ("#id"). KeyDown (function () {});

#* #获取焦点 Monitor enter#*#

Monitor the entire body of the KeyPress event, if it is the return key, the Click event to excite the submit button, of course, your click event will have related data validation and so on, if the verification, will not be submitted.

I hope this article will help you with JSP program design.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.