JavaScript Form Form Technology Summary (recommended) _javascript tips

Source: Internet
Author: User

Here does not carry on the very complex background verification as well as the JavaScript regular expression, simply introduces this technique, the simple backstage receives with jumps, probably understands how verifies can. Specific technology, I will continue to write a blog later. I am also in the study.

Form Validation 1-Simple validation

For simple verification, the username must be ABCD and the password must be greater than or equal to 6
Then, based on the data entered by the user, give a hint later.

Code Demo:

 

360 Browser 8.1 Demo results:

User name does not conform to the rule:


The password does not conform to the rule:


Verification of the Registration Form 2-Regular expression

Code Demo:

 

360 Browser 8.1 Demo results:

Just need to contain 4 consecutive letters.

Registration Form verification and control submission – front-end checksum:

code file Creation Location:

Code Demo:

3form3.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.

will automatically give us a good match web.xml

 package cn.hncu.user; import java.io.IOException; import java.io.PrintWriter; import Java
X.servlet.servletexception;
Import Javax.servlet.http.HttpServlet;
Import Javax.servlet.http.HttpServletRequest;
Import Javax.servlet.http.HttpServletResponse; 
public class Regservlet extends HttpServlet {public void doget (HttpServletRequest request, httpservletresponse response) Throws Servletexception, IOException {doPost (request, response);} public void DoPost (HttpServletRequest request, Httpse Rvletresponse response) throws Servletexception, IOException {request.setcharacterencoding ("utf-8");//Set Encoding String
Name = Request.getparameter ("UserName");//username the name attribute String pwd = request.getparameter ("pwd") of one input in the submitted form;
SYSTEM.OUT.PRINTLN (name);
Request.setattribute ("UName", "Hncu---" +name);
Request.setattribute ("pwd", "pwd---" +pwd);
Request.getrequestdispatcher ("/dhtml/6formsubmit/jsps/show.jsp"). Forward (request, response); Output, directed to another page display}} 

Xml

<?xml version= "1.0" encoding= "UTF-8"?> <web-app version=
"2.5" xmlns= "http://java.sun.com/xml/ns/" 
Java ee " 
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's my
Java EE component</ Description>
<display-name>this is the display name of my Java EE 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 Browser 8.1 Demo Pictures:

When the format is all filled out correctly, click the Register button and automatically jump to another page.


When there is a format error, the DOT registration button will not react.

Registration Form verification and control submission – front-end checksum-final version:

Code Demo:

 

360 Browser 8.1 Demo results:

The registration button will respond only if the full format is filled in correctly.


Full format filled in correctly, after the point of Registration button page, in fact, is to jump to the show.jsp page. (I can locate it wherever I want)

The above is a small set of JavaScript to introduce the form of Forms Form Technology Summary (recommended) related knowledge, hope to help everyone, if you have questions welcome to my message, small series will promptly reply to everyone!

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.