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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sachin SinghPosted Nov 2, 2021, 9:47 AM
Mithun PradhanPosted Nov 18, 2021, 7:08 AM
Mithun PradhanPosted Nov 2, 2021, 9:34 AM
Vikas PanwarPosted Nov 2, 2021, 7:33 AM
$('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"
/>
Sachin SinghPosted Nov 2, 2021, 5:39 AM