File extension validation Javascript
// February 27th, 2008 // 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;
}
}
Related posts:
- Disable right-click contextual menu You can disable right-click contextual menu in your website using...
- Font resizing using jQuery Font Resizing is a very common feature in many modern...











Its really helpful for me……….Thank u.