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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -