In validation js, SyntaxError: missing formal parameter
In validation js, SyntaxError: missing formal parameter
我在 jQuery 中有语法错误 selector.I 我使用 ajax 添加多行并尝试使用 validation.js..
在客户端验证它
在控制台中,我看到错误
"SyntaxError: missing formal parameter".
$(document).ready(function(){
$( "#bookingadd" ).validate({
$('input[type=text]').each(function(){
$(this).rules( "add", "required");
});
$('select').each(function(){
$(this).rules( "add", "selectsubservices"); // value is not 0
});
submitHandler: function (){
setTimeout(function(){}, 2000);
jQuery("#bookingadd").submit();
}
});
});
我使用此代码验证文本框和下拉菜单
我加了console screen
您在某处遗漏了“)”或“}”。尝试找出其他你可以节省
根据 Sparky 的评论修改了我的 post。我应该在 posting 之前参考 jquery 验证选项。
请参考他的回答,我已经相应地修改了我的代码:
$(document).ready(function(){
$("#bookingadd").validate({
submitHandler: function (form){
form.submit();
}
});
$.each($('input[type=text]'),function(){
$(this).rules( "add", "required");
});
$.each($('select'),function(){
$(this).rules( "add", "selectsubservices"); // value is not 0
});
});
您使用 .validate()
方法的尝试:
$( "#bookingadd" ).validate({
$('input[type=text]').each(function(){
$(this).rules( "add", "required");
....
您不能在 .validate
中放置 .each()
函数!您只能放置由 options that are provided by the developer.
组成的 key:value
对的逗号分隔列表
此外,.rules()
方法是一个独立的 jQuery 验证方法,永远不会进入另一个 jQuery 验证方法。
您的结构应该看起来更像这样...
$(document).ready(function() {
$( "#bookingadd" ).validate({
submitHandler: function (form) { // <- you missed the 'form' argument
....
form.submit(); // <- you can use the 'form' argument here
/* you don't need the timer here,
so if you remove it, then there is
no point in having the 'submitHandler' at all,
as 'form.submit()' is already the default.
Just remove the 'submitHandler' entirely. */
}
}); // end .validate()
$('input[type=text]').each(function() {
$(this).rules( "add", "required");
});
$('select').each(function() {
$(this).rules( "add", "selectsubservices"); // value is not 0
});
});
我在 jQuery 中有语法错误 selector.I 我使用 ajax 添加多行并尝试使用 validation.js..
在客户端验证它在控制台中,我看到错误
"SyntaxError: missing formal parameter".
$(document).ready(function(){
$( "#bookingadd" ).validate({
$('input[type=text]').each(function(){
$(this).rules( "add", "required");
});
$('select').each(function(){
$(this).rules( "add", "selectsubservices"); // value is not 0
});
submitHandler: function (){
setTimeout(function(){}, 2000);
jQuery("#bookingadd").submit();
}
});
});
我使用此代码验证文本框和下拉菜单
我加了console screen
您在某处遗漏了“)”或“}”。尝试找出其他你可以节省
根据 Sparky 的评论修改了我的 post。我应该在 posting 之前参考 jquery 验证选项。
请参考他的回答,我已经相应地修改了我的代码:
$(document).ready(function(){
$("#bookingadd").validate({
submitHandler: function (form){
form.submit();
}
});
$.each($('input[type=text]'),function(){
$(this).rules( "add", "required");
});
$.each($('select'),function(){
$(this).rules( "add", "selectsubservices"); // value is not 0
});
});
您使用 .validate()
方法的尝试:
$( "#bookingadd" ).validate({
$('input[type=text]').each(function(){
$(this).rules( "add", "required");
....
您不能在 .validate
中放置 .each()
函数!您只能放置由 options that are provided by the developer.
key:value
对的逗号分隔列表
此外,.rules()
方法是一个独立的 jQuery 验证方法,永远不会进入另一个 jQuery 验证方法。
您的结构应该看起来更像这样...
$(document).ready(function() {
$( "#bookingadd" ).validate({
submitHandler: function (form) { // <- you missed the 'form' argument
....
form.submit(); // <- you can use the 'form' argument here
/* you don't need the timer here,
so if you remove it, then there is
no point in having the 'submitHandler' at all,
as 'form.submit()' is already the default.
Just remove the 'submitHandler' entirely. */
}
}); // end .validate()
$('input[type=text]').each(function() {
$(this).rules( "add", "required");
});
$('select').each(function() {
$(this).rules( "add", "selectsubservices"); // value is not 0
});
});