使用语义UI表单,模态和验证,我有一个模式的表单,如果表单无效(在提交时发生),我不希望模式关闭。在提交之前听取语义UI表单验证错误
我可以阻止模式关闭的唯一方法是将disabled
类添加到提交按钮。
我想根据当前表单验证状态来实时地收听表格并切换disabled
类。
我只能得到一次形式实时提交,但不
$('#myForm')
.form({
title: {
identifier : 'title',
rules: [
{
type : 'empty',
prompt : 'Please enter a title'
},
{
type : 'length[2]',
prompt : 'At least 6 characters'
}
]
}
},
{
onSuccess: function() {
$('#submit').removeClass('disabled');
},
onFailure: function() {
$('#submit').addClass('disabled');
}
}
);
这是完美的 - 正是我需要的 –