bUgS oF a DEeBugGEr

Wednesday, February 27, 2008

File extension validation Javascript

You can use this function to validate the extension of a file.

// function to validate the extension of a file

// 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; }

Labels: , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home