.

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;
	}
}
  • Share/Bookmark

Related posts:

  1. Font resizing using jQuery Font Resizing is a very common feature in many modern...

One Response to “File extension validation Javascript”

  1. shaswati says:

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

Leave a Reply