You need to sign in to do that
Don't have an account?
pranavshah
File Extension validation
Hi All,
I Want to give Some Validation to File Extemsion...So that it should accept particular file Format.....
i have Written these
function check(obj) {
var path = obj.value;
var ext = path.substring(path.lastIndexOf('.') + 1);
if(ext !="pdf")
{
obj.value = null;
window.alert("File can be only of type : pdf, doc, docx, xls, xlsx, ppt, pptx, pps, ppsx ");
return false;
}
}
but its not Working..i want to give validation for 5-6 file Format...how it will be Written,, Kindly Suggest.
I Want to give Some Validation to File Extemsion...So that it should accept particular file Format.....
i have Written these
function check(obj) {
var path = obj.value;
var ext = path.substring(path.lastIndexOf('.') + 1);
if(ext !="pdf")
{
obj.value = null;
window.alert("File can be only of type : pdf, doc, docx, xls, xlsx, ppt, pptx, pps, ppsx ");
return false;
}
}
but its not Working..i want to give validation for 5-6 file Format...how it will be Written,, Kindly Suggest.
As far as I see you trying to get file extension wih javascript. Please see the following thread in stackowerflow
http://stackoverflow.com/questions/190852/how-can-i-get-file-extensions-with-javascript
for instance you can use
If you know the expected extension you could use instead filename.replace('.pdf', '');