JQuery Form Verification plug-in jQuery. validate. js

Source: Internet
Author: User

Today, I downloaded jquery. validate. js and read the demo provided by jquery. validate. js. Now let's summarize the notes.

Jquery. validate. js official website download: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

You can download the example program and js script from the above.

Note: I have read the example program. please correct me if there is anything wrong with it. Thank you!

There are two ways to use it to verify the form:

1. Use the internally defined verification (that is, the error message indicates that it has been defined. We do not need to define it again. This is convenient and simple. But not flexible .)

2. custom error prompt. You can customize the error prompt by yourself. There is a lot of code to be written.

Instance 1. Use jquery to verify the defined error message.

I. We first create a form without any verification.

Copy to ClipboardReference: [www.bkjia.com] <% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "Default. aspx. cs "Inherits =" jquery_asp.net. _ Default "%>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> jquery validate </title>
</Head>
<Body>
<Form id = "commentForm" method = "get" action = "">
<Fieldset>
<Legend> enter your name, email, URL, and comment </legend>
<P>
<Label for = "cname"> name (required and 2 characters) </label>
<Input id = "cname" name = "name"/>
<P>
<Label for = "cemail"> email (required) </label>
<Input id = "cemail" name = "email"/>
</P>
<P>
<Label for = "curl"> URL (optional) </label>
<Input id = "curl" name = "url" value = ""/>
</P>
<P>
<Label for = "ccomment"> your comment (required) </label>
<Textarea id = "ccomment" name = "comment"> </textarea>
</P>
<P>
<Input type = "submit" value = "submit"/>
</P>
</Fieldset>
</Form>
</Body>
</Html>

2. Add Verification

Now let's add verification.

1. Introduce the jquery script

<Script type = "text/javascript" src = "http://www.bkjia.com/uploads/Common/jquery-1.3.2.min.js"> </script>
<Script src = "http://www.bkjia.com/uploads/Common/js/jquery.validate.js" type = "text/javascript"> </script>

  • 2 pages in total:
  • Previous Page
  • 1
  • 2
  • Next Page

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.