欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery內(nèi)置驗證(validate)使用方法示例(表單驗證)

 更新時間:2013年12月04日 16:42:52   作者:  
這篇文章主要介紹了jquery內(nèi)置驗證(validate)使用方法示例,在做表單驗證的時候可以用到,下面看代碼使用方法

(1)required:true 必輸字段
(2)remote:"check.php" 使用ajax方法調(diào)用check.php驗證輸入值
(3)email:true 必須輸入正確格式的電子郵件
(4)url:true 必須輸入正確格式的網(wǎng)址
(5)date:true 必須輸入正確格式的日期
(6)dateISO:true 必須輸入正確格式的日期(ISO),例如:2009-06-23,1998/01/22 只驗證格式,不驗證有效性
(7)number:true 必須輸入合法的數(shù)字(負(fù)數(shù),小數(shù))
(8)digits:true 必須輸入整數(shù)
(9)creditcard: 必須輸入合法的信用卡號
(10)equalTo:"#field" 輸入值必須和#field相同
(11)accept: 輸入擁有合法后綴名的字符串(上傳文件的后綴)
(12)maxlength:5 輸入長度最多是5的字符串(漢字算一個字符)
(13)minlength:10 輸入長度最小是10的字符串(漢字算一個字符)
(14)rangelength:[5,10] 輸入長度必須介于 5 和 10 之間的字符串")(漢字算一個字符)
(15)range:[5,10] 輸入值必須介于 5 和 10 之間
(16)max:5 輸入值不能大于5
(17)min:10 輸入值不能小于10

實例Demo:

復(fù)制代碼 代碼如下:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>validate.js內(nèi)置驗證規(guī)則的使用</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.validate.js"></script>
</head>
<body>
<form action=""  method="get" id="tinyphp">
<input type="text" value="" name="userName" />
<input type="submit" value="提交" />
</form>
<script type="text/javascript">
$("#tinyphp").validate({
    // 添加驗證規(guī)則
    rules: {
        userName:{
            required: true,
            digits:true,
            userName: true,
            rangelength: [5,10]   
        }
    },

    //重設(shè)提示信息
    messages:{
        userName: {
            required: "請?zhí)顚懹脩裘?,
            digits:"請輸入整數(shù)",
            rangelength: "用戶名必須在5-10個字符之間"
        }      

    }
}); 
    </script>
</body>
</html>

相關(guān)文章

最新評論