Reputation: 9855
I'm trying to run a function if a file input type is pdf.
Does anybody know of a way i can validate the file extension with jQuery before hand? thanks
$('.uploadCV').click(function () {
if ($('.html-btn').val() === '.pdf') {
$('.join-us').flip({
direction: 'rl',
color: '#38404b',
speed: 200,
onAnimation: function () {
$('.icon').fadeOut();
$(this).css('margin-top', '20px');
},
content: '<span class="title">Uploading...</span><span class="summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>'
})
} else {
console.log('dont upload');
}
});
Upvotes: 0
Views: 4701
Reputation: 665
In this plugin you can determine what extension can to upload Jquery Multiple File Upload Demo
Upvotes: 0
Reputation: 57095
You can check file extension .pdf
var val = $('.html-btn').val();
var file_type = val.substr(val.lastIndexOf('.')).toLowerCase();
if (file_type === '.pdf') {
References
Upvotes: 3