Copy codeThe Code is as follows:
<% @ Page language = "java" pageEncoding = "gbk" %>
<Html>
<Head>
<Title> jqueryValidateDemo </title>
<Script type = "text/javascript" src = "js/jquery. js"> </script>
<Script type = "text/javascript" src = "js/jquery. validate. js"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ("# Login"). validate ({
Rules :{
Name :{
Required: true
},
Password :{
Required: true,
Minlength: 4
}
},
Messages :{
Name :{
Required: "This item is required"
},
Password :{
Required: "This item is required ",
Minlength: "The password must contain at least four characters"
}
}
})
});
</Script>
</Head>
<Body>
<Form action = "" id = "login" method = "post">
<Table align = "center" border = "1">
<Tr>
<Td> login name </td>
<Td> <input type = "text" id = "name" name = "name"/> </td>
</Tr>
<Tr>
<Td> password </td>
<Td> <input type = "password" id = "password" name = "password"/> </td>
</Tr>
<Tr>
<Td align = "center" colspan = "2"> <input type = "submit" value = "register"/> </td>
</Tr>
</Table>
</Form>
</Body>
</Html>