you need to upload only text file or what ? @vandan
Feb 10, 2020
11
Level 13
validation txt,doc,pdf file using javascript
i use validation using javascript but when i upload text file then validation error how to check extesion in javascript
here is my script
<script>
$('button[type="submit"]').prop("disabled", true);
var a=0;
$('#idproof').bind('change', function() {
if ($('button:submit').attr('disabled',false)){
$('button:submit').attr('disabled',true);
}
var ext = $('#idproof').val().split('.').pop().toLowerCase();
if ($.inArray(ext, ['gif','png','jpg','jpeg','text','rtf','doc','pdf']) == -1){
$('#error1').slideDown("slow");
a=0;
}else{
$('#error1').slideUp("slow");
if (a==1){
$('button:submit').attr('disabled',false);
}
}
});
</script>
here is my blade file
<input type="file" name="idproof" id="idproof">
<p id="error1" style="display:none; color:#FF0000;">
Invalid Image Format! Image Format Must Be JPG, JPEG, PNG, DOC ,TXT, PDF.
Please or to participate in this conversation.