私はHTMLからonchange関数を呼び出しています。これは、初めて期待どおりに動作します。しかし、二度目はそうではありません。デバッガでさえ関数にヒットしていません。変更が2回目で機能しない
HTML
@Html.TextBoxFor(m => m.Attachment.AttachmentFile, new { type = "file", onchange = "GetAttachmentFileName()", style = "display:none" })
はJavaScript
function GetAttachmentFileName() {
$("#Filesize").hide();
if ($("#Attachment_AttachmentFile").val() != null && $("#Attachment_AttachmentFile").val() != "") {
var filename = $("#Attachment_AttachmentFile").val().split('\\').pop().replace(" ", "");
$("#Attachment_StorageName").val(filename);
$("#filename").val(filename);
$("#attachmentFileerror span").css("display", "none");
var fileSize=0;
var maxFileSize = 10240000 // 10MB -> 10000 * 1024
fileSize = $("#" + "Attachment_AttachmentFile")[0].files[0].size //size in kb
if(fileSize>maxFileSize){
$("#Filesize").html("Please choose file less than 10MB");
$("#Filesize").css("display", "block");
$('#filename').val('');
}
else{
$("#Filesize").css("display", "none");
}
}
else
$("#Attachment_StorageName").val("");
}
ありがとうリオンの編集が...あなたの助けに感謝作るため。 – John