“成功”功能是如何运作的,我该如何模仿它
How does the `success` function work and how can I imitate it?
我正在开发一个验证框架,需要一个布尔值结果来知道验证是否成功。
这里是我正在做的快速查看:
Stone.Validation({
id: "#InputTextId",//the id of the input you want to validate
DataType: "string",//the Data Type of want to valide(string and integer for now are avaiable)
MsgOk: "Correct",//optional: the msg you want to display if it is a string
MsgWrog: "* Check this field",////optional: the msg you want to display if its not a string
Destiny: "#someDivID",//the id that will some the correct of error message
})
我不知道如何禁用表单提交,如果验证失败。它只是返回消息,而不是布尔值或类似的东西。
我要找的例子:
Stone.Validation({
id: "#InputTextId",
DataType: "string",
MsgOk: "Correct",
MsgWrog: "* Check this field",
Destiny: "#someDivID",
success: function(results)
{
if(results)
{
//submit will work
}
}
})
要控制表单提交,必须使用表单的submit事件。下面是如何使用jQuery实现这一点:
$('form').submit(function(){
// validate your form first
if(!formIsValid) {
// if validation didn't pass, cancel submission
return false;
}
});
相关文章:
- “createImageData()”和“new ImageData(()”有何不同
- 这与 $(document).ready() 有何不同
- XUL文档与HTML文档对象有何不同
- Javascript对象:这两个值有何不同
- 什么是声明性环境记录,它与激活对象有何不同
- 响应式 Web 开发与渐进式 Web 开发有何不同
- 这个最终数字从何而来
- Sencha Touch 2 它与我对 html5/javascript Web 开发的知识有何关系
- 我的 for 循环中的这些小数从何而来
- 在《春面孔》中,点击事件从何而来
- 是否有可能知道用户何时点击YouTube视频上的广告
- JSON 与序列化有何关系
- 数组排序.论点从何而来
- jQuery.queue() 与使用回调函数完成某事有何不同
- 这第二场比赛从何而来
- ShadowDOM vs Document Fragments -- 它们有何不同
- 使用用于在同一函数中命名函数的变量名称有何意义
- $scope函数参数从何而来
- 滚动条从何而来,如何删除它
- 在 JavaScript 中命名匿名函数有何不同