Summary of Form Technology in JavaScript (recommended), javascriptform

Source: Internet
Author: User

Summary of Form Technology in JavaScript (recommended), javascriptform

Here, we will not perform complicated background verification and JavaScript Regular Expressions. We will simply introduce this technology, simply receive and jump to the background, and you will probably know how to verify it. I will continue to write blogs for specific technologies later. I am still learning.

Form Verification 1-simple verification

For simple verification, the user name must be abcd and the password length must be greater than or equal to 6
Then, based on the data entered by the user, a prompt is provided later.

Code Demonstration:

<Html> 

360 Demonstration Result of browser 8.1:

The username does not comply with the following rules:


The password does not comply with the rules:


Verification of a registry ticket 2-Regular Expression

Code Demonstration:

<Html> 

360 Demonstration Result of browser 8.1:

It only needs to contain four consecutive letters.

Verify the registration form and control the submission-front-end verification:

Code File Creation location:

Code Demonstration:

3form3.html

<Html> 

Show. jsp:

<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% @ taglib uri =" http://java.sun.com/jsp/jstl/core "prefix =" c "%> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"> 

RegServlet. Java

This is a new Servlet.

The web. xml file is automatically configured for us.

Package cn. hncu. user; import java. io. IOException; import java. io. printWriter; import javax. servlet. servletException; import javax. servlet. http. httpServlet; import javax. servlet. http. httpServletRequest; import javax. servlet. http. extends; public class RegServlet extends HttpServlet {public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doPost (request, response);} public void doPost (HttpServletRequest request, httpServletResponse response) throws ServletException, IOException {request. setCharacterEncoding ("UTF-8"); // you can specify the encoding String name = request. getParameter ("userName"); // userName is the name attribute of an input in the submitted Form String pwd = request. getParameter ("pwd"); // System. out. println (name); request. setAttribute ("uName", "hncu ---" + name); request. setAttribute ("pwd", "pwd ---" + pwd); request. getRequestDispatcher ("/dhtml/6 formsubmit/jsps/show. jsp "). forward (request, response); // output, directed to another page display }}

Web. xml

<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><display-name></display-name><servlet><description>This is the description of my J2EE component</description><display-name>This is the display name of my J2EE component</display-name><servlet-name>RegServlet</servlet-name><servlet-class>cn.hncu.user.RegServlet</servlet-class></servlet><servlet-mapping><servlet-name>RegServlet</servlet-name><url-pattern>/servlet/RegServlet</url-pattern></servlet-mapping> <welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>

360 demonstration image of browser 8.1:

When the format is correct, click the register button to automatically jump to another page.


If a format error occurs, clicking the register button does not respond.

Verify and control the submission of the Registry ticket-front-end verification-final version:

Code Demonstration:

<Html> 

360 Demonstration Result of browser 8.1:

The response is returned only when you click the register button after entering all the correct formats.


After entering all the formats correctly, click "register" to go to the show. jsp page. (Where can I find it)

The above is a summary (recommended) of Form Technology in JavaScript. I hope it will be helpful to you. If you have any questions, please leave a message, the editor will reply to you in time!

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.