相同的功能正在其他页面上运行,但在这里它调用了该功能,显示警报但仍然表单提交并返回 false 不起作用.....我正在使用视图剃须刀
@using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
这是我的提交按钮
<input type="submit" value="Submit" id="demo-submit-button"/>
非常感谢
$(function () {
$('form').submit(function () {
//alert($("input[type=radio]:checked").val());
if ($("input[type=radio]:checked").val() == "True") {
//Logo Image
var selectedFile = $('#imgfile').val();
if (selectedFile == "") {
alert('please select valid image logo for marketplace');
return false;
}
else {
var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp'];
if ($.inArray($('#imgfile').val().split('.').pop().toLowerCase(), fileExtension) == -1) {
alert("You are permited to select only '\n.jpeg','.jpg', '.png', '.gif', '.bmp' formats are allowed.");
return false;
}
}
//Screenshots
if ($('#ssimgfile').val() == "" || $('#ssimgfile1').val() == "" || $('#ssimgfile2').val() == "") {
alert('please select valid screenshots for marketplace');
return false;
}
else {
var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp'];
if ($.inArray($('#ssimgfile').val().split('.').pop().toLowerCase(), fileExtension) == -1 || $.inArray($('#ssimgfile1').val().split('.').pop().toLowerCase(), fileExtension) == -1 || $.inArray($('#ssimgfile2').val().split('.').pop().toLowerCase(), fileExtension) == -1) {
alert("You are permited to select only '\n.jpeg','.jpg', '.png', '.gif', '.bmp' formats are allowed.");
return false;
}
else {
return true;
}
}
}
});
});