How to Validate on button submit,
How to Validate on button submit,
Know the answer? Post it. Somebody with the same question will find it here.

$('INPUT[type="file"]').change(function () {
var ext = this.value.match(/\.(.+)$/)[1];
switch (ext) {
case 'jpg':
case 'jpeg':
case 'png':
case 'gif':
$('#uploadButton').attr('disabled', false);
break;
default:
alert('This is not an allowed file type.');
this.value = '';
}});
For the front-end it is good convenient to put 'accept' attribute like as.
accept="image/jpg,image/png,image/jpeg,image/gif"
/>
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Nov 2, 2021, 5:47 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Nov 2, 2021, 1:39 AM EDT