我是PHP新手,我想在我的PHP項目中應用jQuery驗證。這裏是jQuery的代碼,你能找到本節中的錯誤。jQuery驗證規則不適用於PHP
(function($,W,D)
{
var JQUERY4U = {};
JQUERY4U.UTIL =
{
setupFormValidation: function()
{
//form validation rules
$("#register-form").validate({
rules: {
username: "required",
joindate: "required",
location: "required",
aboutme: "required",
fileupload: "required",
emailid: {
required: true,
email: true
},
password: {
required: true,
minlength: 5
},
agreement: "required"
},
messages: {
username: "Please enter your username",
joindate: "please enter join date",
location: "please enter your location",
aboutme: "please write about urself",
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
emailid: "Please enter a valid email address",
fileupload: "Please upload a valid image",
agreement: "Please accept our terms and policy"
},
submitHandler: function(form) {
form.submit();
}
});
}
}
//when the dom has loaded setup form validation rules
$(D).ready(function($) {
JQUERY4U.UTIL.setupFormValidation();
});
})(jQuery, window, document);
歡迎SO。我不認爲'$(D).ready(函數)是正確的 –
@JamesWong - 它是當你傳遞奇怪的論點給一個IIFE。 – adeneo
這將有助於,如果你描述了什麼問題,並添加了HTML也。 –