$(function(){ var rules = { "coupon_amount" : [/^0.([1-9]){1,2}$/,"必須為0.85這樣的數字"] } $.skygqCheckAjaxForm.addRules(rules); //第二個表單驗證 var items_array2 = [ { name:"info[login]",type:"username",simple:"使用者名稱",message:"搞什麼飛機,好好填寫使用者名稱",focusMsg:'數字和英文及底線和.的組合,開頭為字母,4-20個字元',ajax:{method:'post',url: base_url+'skygq_check_ajax_form_1_5/ajax.html',success_msg:'恭喜!使用者名稱可用',failure_msg:'使用者名稱已存在'}}, { name:"info[password]",type:'password',simple:"密碼",focusMsg:'最小長度:6 最大長度:16'}, { name:"info[confirm_password]",type:'eq',to:'info[password]',simple:"確認密碼",focusMsg:'請再輸入一遍您上面填寫的密碼'}, { name:"info[email]",type:"mail",simple:"Email",focusMsg:'請填寫真實並且最常用的郵箱'}, { name:"info[age]",simple:"年齡",between:[18,78],focusMsg:'年齡必須大於等於18小於等於78'}, { name:"info[do_years]",simple:"工作年限",type:"gt",value:3,focusMsg:'必須大於3'}, { name:"sport[]",simple:"運動",checked_limit:[2,2],focusMsg:"請選擇2項運動"}, { name:"favourite[]",simple:"愛好",checked_limit:[4,7],focusMsg:"請選擇4到7項愛好"}, { name:"sky.zhekou",type:"coupon_amount",simple:"折扣",focusMsg:"請填寫折扣係數"} ]; $("#form2").skygqCheckAjaxForm({ items : items_array2, isAjaxSubmit : true, success : showResponse2, dataType : 'json' }); function showResponse2(responseText, statusText, xhr, $form) { alert("註冊成功") alert("JSON返回資料為:" + responseText); } }); |