File extension validation Javascript
You can use this function to validate the extension of a file, for client side file upload checkes.
// You can specify the file type in the code "valid_extensions = /(.doc|.pdf)$/i;" .
//If you want to add .docx supprt simply add |.docx (ex:(.doc|.pdf |.docx| .your-extension) )
var valid_extensions = /(.doc|.pdf)$/i;
function CheckExtension(fld)
{
if(fld.value) {
if (valid_extensions.test(fld.value)){
return true;
} else {
return false;
}
} else {
return true;
}
}
Its really helpful for me……….Thank u.
thankx for code…..short n very useful
Thanks a lot… saved lot of my efforts