Key*_*ger 6 validation jquery jquery-ui jquery-plugins
我在提交表单时使用jQuery和验证插件:
$('.frmProject:visible').validate( {
errorContainer: ".site_details:visible .messageBox1",
errorLabelContainer: ".site_details:visible .messageBox1 span.messagehere",
invalidHandler: function(form, validator) {
},
rules: {
site_id: {
required: true,
}
},
messages: {
site_id: "Project has no assigned site information. Click the marker on the map at left to specify the site where this project took place."
},
submitHandler: function(data) {
SaveProject();
}
});
Run Code Online (Sandbox Code Playgroud)
在submitHandler中,
function SaveProject(){
//... load variables with input contents
$.ajax({
url: 'ajax/save_project.php',
dataType: 'json',
data: 'id='+id+'&title='+title+'&project='+project+'§or='+sector+'&volunteer='+volunteer+'&lat='+lat+'&lng='+lng+'&name='+name+'&mun='+mun+'&prov='+prov,
success: function(data) {
//... load 'messages' object with stuff
$.each(messages, function(key, value) {
if (confirm(key)){
console.log(item);
}
});
}
});
}
Run Code Online (Sandbox Code Playgroud)
当我提交经过验证的表单并在每个循环中进入确认时,我收到错误消息:"确认不是函数".
如何向用户显示消息以进行确认?
编辑:
当我在控制台中键入"确认"时,我得到了这个:

检查DOM显示:
window> confirm()此对象没有要显示的属性.
在Script中检查将我带到了jquery-1.6.2.min.js中的一个位置
sis*_*onb 16
confirm方法是window对象的一部分.
if (window.confirm(key)){
console.log(item);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22292 次 |
| 最近记录: |