inp*_*put 1 database validation jquery object submit
由于jquery,由于某些奇怪的原因,我收到错误"对象预期",并且这不会"提交"表单或将数据输入数据库.
没有jquery,数据可以输入数据库.但现在却没有.
我使用jquery主要用于验证asp.net控件.
roosteronacid,验证工作完全正常,id属性也相同.提交只是没有执行服务器端代码,我无法弄清楚是什么问题.
编辑:
这是jquery代码:
<script type="text/javascript">
$(document).ready(function() {
// add custom validation methods
$.validator.addMethod('phone', function(value, el, params) {
return this.optional(el) || /^[0-9,+,(), ,]{1,}(,[0-9]+){0,}$/.test(value);
}, 'Please enter a valid phone number');
$.validator.addMethod('numbers', function(value, el, params) {
return this.optional(el) || /^[0-9]+$/.test(value);
}, 'Invalid entry. Only Numeric is allowed.');
$.validator.addMethod('domainurl', function(value, el, params) {
return this.optional(el) || /^(http\:\/\/(?:www\.)?[a-zA-Z0-9]+(?:(?:\-|_)[a-zA-Z0-9]+)*(?:\.[a-zA-Z0-9]+(?:(?:\-|_)[a-zA-Z0-9]+)*)*\.[a-zA-Z]{2,4}(?:\/)?)$/.test(value);
}, 'Please enter a valid domain url');
$.validator.addMethod('selectone', function(value, element) {
return this.optional(element) || (value.indexOf("none") == -1);
}, 'Please select an option.');
$("#form1").validate({
debug: true,
rules: {
txt_name: {
required: true,
minlength: 2
},
txt_cmp: {
required: true,
minlength: 2
},
txt_tel1: {
phone: true,
required: true,
minlength: 3
},
txt_tel2: {
phone: true,
required: false,
minlength: 3
},
txt_mob: {
phone: true,
required: false,
minlength: 9
},
txt_email: {
required: true,
email: true
},
txt_domname: {
required: true,
domainurl: true
},
radiobt_domain: "required",
ddl_yremail: {
required: true,
selectone: true
},
ddl_email: {
required: true,
selectone: true
},
txt_space: {
required: true,
numbers: true
},
txt_calfr: {
required: true
},
txt_calto: {
required: true
}
},
messages: {
txt_name: {
required: "This field is required",
minLength: "Please enter a valid name"
},
txt_cmp: {
required: "This field is required",
minLength: "Please enter a valid commpany name"
},
txt_tel1: {
required: "This field is required",
minLength: "Please enter a valid telephone number"
},
txt_tel2: {
minLength: "Please enter a valid telephone number"
},
txt_mob: {
minLength: "Please enter a valid mobile number"
},
txt_email: {
email: "Please enter a valid email address",
required: "This field is required"
},
txt_domname: {
required: "This field is required"
},
radiobt_domain: "Select the Hosting Type"
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
代码有什么问题吗?
它说在559行预期的对象.我检查了jquery.validate.js文件,这是它显示的代码:
addWrapper: function(toToggle) {
if ( this.settings.wrapper )
toToggle = toToggle.add( toToggle.parents( this.settings.wrapper ) );
return toToggle;
}
Run Code Online (Sandbox Code Playgroud)
jquery代码显示正确位置的所有错误,但一旦更正,它就不会提交数据.
我正在使用的插件:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
当您尝试访问未定义,未引用或错误拼写错误的对象时,会发生预期的对象.检查预期的对象.使用Firefox firebug调试你的javascript或使用IE进行调试,以获取运行时无法找到的对象....
| 归档时间: |
|
| 查看次数: |
11407 次 |
| 最近记录: |