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