Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement jQuery plug-in Validation form validation

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today Xiaobian to share with you about the jQuery plug-in Validation form verification of how to achieve the relevant knowledge, detailed content, clear logic, I believe that most people are too aware of this knowledge, so share this article for your reference, I hope you have something to gain after reading this article, let's take a look at it.

Function

1. The required and length of "name" is at least two-digit verification.

two。 Verification of the required and E-mail format for "email".

3. Verification of whether the "URL" is url.

4. Verify whether "your comments" is required.

Result diagram

Examples

Get started quickly * {font-family:Verdana; font-size:96%;} label {width:10em; float:left} label.error {float:none; color:red; padding-left:.5em; vertical-align:top;} p {clear:both} .submit {margin-left:12em;} em {font-weight:bold; padding-right:lem; vertical-align:top;} $(document) .ready (function () {$("# commentForm") .validate ();}) A simple example of a comment with a verification hint

Name *

Email *

Web site

Your comments *

Code analysis

1.jQuery code

$(document) .ready (function () {$("# commentForm") .validate ();})

Lines 1 and 2 import the jQuery class library and the Validation plug-in.

The purpose of line 4 is to execute the code in function after the contemporary code has been loaded

Line 5 is to determine which form needs to be validated.

two。 Encode the verification rules for different fields and set the corresponding properties of the field

Class= "required" is required

Class= "required email" is required and conforms to E-mail format.

Class= "url" validates to url format

Minlength= "2" is the minimum length is 2

These are all the contents of the article "how to implement jQuery plug-in Validation form validation". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report