2012-08-07 30 views
0
$.validator.addMethod("noanon", function(value) { 
return ajaxFunction(); 
}, 'Username already exists.'); 

的addMethod函數有3個參數。名稱,實際運行的邏輯,以及最後用於失敗的默認消息。如何檢查jQuery驗證程序中是否存在使用AJAX的值?

name: { 
required: true, 
minlength: 2, 
noanon: true 
}, 

現在,如果我用ajaxFunction,有中小企業是其中出現了一些錯誤。

回答

1

您可以使用remote方法:

rules: { 
    name: { 
     remote : "script.php" 
    } 
}, 
messages: { 
    name: { 
     remote : "Page with this name is exists" 
    } 
} 

在PHP你把$_GET['name']

補充信息here

相關問題