我正在使用jquery-steps 插件。现在我正在尝试检查文件扩展名是否为 .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。第三个问题是,当我们单击快速下一步按钮时,它会在没有验证的情况下传递到下一步