javascript - JS file upload validation, but instant in windows window -
i have form , did validation in js, form not send when user sends sth different .doc/.docx. (cv uploading). want faster. error instantly when file selected, not when button submitted. (in windows window).
how it? it's standard form:
<div class="form-group"> <label>your cv</label> <input required type="file" accept="application/msword" class="form-control" name="cv" id="cv" aria-describedby="name" placeholder="select cv file"/> </div>
i've got answer. here's code (isdoc own function):
function onchange(event) { var file = $('#file_cv')[0].files[0]; if ( !isdoc(file.name) ) { alert("please, choose .doc or .docx type."); document.getelementbyid("file_cv").value=""; } }
now, it's impossible submit form without sending proper file.
Comments
Post a Comment