`

Jquery之表单验证 小李子

阅读更多
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Myindex.html</title>
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
        <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
        <script src="js/jquery.js" type="text/javascript">
        </script>
        <script src="js/jquery.validate.js" type="text/javascript">
        </script>
        <script src="js/cmxforms.js" type="text/javascript">
        </script>
        <script type="text/javascript">
            $().ready(function(){
                $("#myform").validate({
                    rules: {
                        username: 'required',
						password:{
							required:true,
							minlength:2
						}
                    },
                    
                    messages: {
                        username: '用户名必须输入',
						password:{
							required:"密码必须输入",
							minlength:"长度不能小于2"
						}
                    }
                });
            });
        </script>
    </head>
    <body>
        <form id='myform'>
            用户名:<input type='text' name="username" class='required'>
            <br>
            密码:<input type='password' name="password" class='required'>
            <br>
            EMAIL:<input type='email' name="emial" class='required email'>
            <br>
            <input type="submit" value="提交">
        </form>
        <br>
    </body>
</html>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Myindex.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> <script src="js/jquery.js" type="text/javascript"> </script> <script src="js/jquery.validate.js" type="text/javascript"> </script> <script src="js/cmxforms.js" type="text/javascript"> </script> <script type="text/javascript"> $().ready(function(){ $("#myform").validate(); }); </script> </head> <body> <form id='myform'> 用户名:<input type='text' name="username" class='required'><br> 密码:<input type='password' name="pwd" class='required'><br> EMAIL:<input type='email' name="emial" class='required email'><br> <input type="submit" value="提交"> </form> <br> </body> </html>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics