Check file extension in JavaScript
Easy script to check extensions on JavaScript.
function checkExt(e) {//use in a form event or ina input value=e.value; if( !value.match(/\.(jpg)|(gif)|(png)|(bmp)|(pdf)$/) ){//here your extensions alert("wrong extension"); //actions like focus, not validate... } else {//right extension alert("nice!"); //actions } }
Usage example onchange event:
<input id="Path" name="Path" type="file" />Just one that says if is PDF or not:
function isPdf(e) { if( e.value.match(/\.(pdf)$/) ){ alert("pdf"); //action } else alert("no pdf"); //actions }
Same as the other one.
I know they are really simple but I never need it to validate this in the client side since today. Kind of weird xD
Related Posts- PHP Class for better cache - fileCache
- JavaScript to return dimensions
- Word to PDF in PHP
- SEO Functions for PHP
- Add PDF files inside other PDF in PHP
- Adventures with Chase Credit Cards
- What is a Healthy Relationship?
- Deleveraging Is Not Deflation!
- Buying a leased car - Ask the M-Network
- Panasonic ES8043SC Pro-Curve Pivot Action Linear Wet/Dry Shaver, Silver
Help sharing and Flatter me ;)

Great! it worked perfectly!, Thanks for your code. After a very long hunt i found this.
Thanks
Ram
welcome! ;)