I am validating a picture uploaded is jpg or not as below code
alert(fileName);
if (fileName != '') {
alert("Entered if");
var ext = $('#pic').val().split('.').pop().toLowerCase();
if (ext != 'jpg')
{
error = 1;
alert(error);
}
}
If i select any file this validation is passing. So I put two alerts. Now the first alert will show the file path selected. but any how it is not getting inside the if condition so second alert is not doing so no check for the extension is happening. The if condition is true because fileName show the file path so it is not equal to ''
Aucun commentaire:
Enregistrer un commentaire