Skip to content

Instantly share code, notes, and snippets.

@livando
Created November 1, 2011 15:30
Show Gist options
  • Save livando/1330818 to your computer and use it in GitHub Desktop.
Save livando/1330818 to your computer and use it in GitHub Desktop.
quick javascript snippet which uses jQuery and Regular expressions to not allow special characters.
var filename = jQuery("#uploadform #fileName").val();
var characterReg = /^\s*[a-zA-Z0-9\._,\s]+\s*$/;
if(!characterReg.test(filename))
alert("NOT OK " + filename);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment