【发布时间】:2014-03-12 09:20:12
【问题描述】:
我正在使用jquery-steps plugin。现在我试图检查文件扩展名是否为.jpg。除了文件类型检查外,一切正常。它接受一切,但不应该
$("#passportForm").steps({
headerTag: "h1",
bodyTag: "fieldset",
enableFinishButton: false,
transitionEffect: "fade",
stepsOrientation: "vertical",
onStepChanging: function (event, currentIndex, newIndex) {
// Always allow going backward even if the current step contains invalid fields!
if (currentIndex > newIndex) {
return true;
}
var form = $(this);
// Clean up if user went backward before
if (currentIndex < newIndex) {
// To remove error styles
$(".body:eq(" + newIndex + ") label.error", form).remove();
$(".body:eq(" + newIndex + ") .error", form).removeClass("error");
}
// Disable validation on fields that are disabled or hidden.
form.validate({
rules: {field: {required: true,extension: "jpeg|jpg"}}***,
errorPlacement: function (error, element) { }
}).settings.ignore = ":disabled,:hidden";
// Start validation; Prevent going forward if false
return form.valid();
},
onStepChanged: function (event, currentIndex, priorIndex) {
},
onFinishing: function (event, currentIndex) {
var form = $(this);
// Disable validation on fields that are disabled.
// At this point it's recommended to do an overall check (mean ignoring only disabled fields)
form.validate({ errorPlacement: function (error, element) { } }).settings.ignore = ":disabled";
// Start validation; Prevent form submission if false
return form.valid();
},
onFinished: function (event, currentIndex) {
var form = $(this);
form.submit();
}
});
我还需要检查文件大小。它必须小于 3mb。第三个问题是当我们点击快速下一步按钮时,它会在没有验证的情况下进入下一步
【问题讨论】:
标签: javascript jquery jquery-validate jquery-steps