jquery - Uploading a file using hidden input field -


i'm trying call upload file function href link , though browse box being displayed, can't run validation on selected file. here code have:

<a href="#" onclick="$('input[id=formmedia]').click();"><div class="sidebarsectionlink">click here add files</div></a> //calls browse box  <input type="file" id="formmedia" style="display: none;"> //hidden input  //post photo jquery $('#formmedia').blur(function() { var pic=$("#formmedia").val(); if(pic.length < 1){     $('.sidebarsectionlink').html("please add photo").removeclass("success").addclass("error");     picok = 2; } else if(pic.indexof('jpg') === -1 && pic.indexof('jpeg') === -1 && pic.indexof('png') === -1 && pic.indexof('gif') === -1){     $('.sidebarsectionlink').html("invalid file format").removeclass("success").addclass("error");     picok = 2; } else {     picok = 1; } }); 

document.getelementbyid('formmedia').onchange = uploadonchange;  function uploadonchange(){     //validation here } 

or jquery version

$('#formmedia').change(function(){     //validation }); 

because field hidden, onblur won't fire, changes can happen on hidden items.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -