Detect some conflictive characters in a string with javascript
Posted
by
FranQ
on Stack Overflow
See other posts from Stack Overflow
or by FranQ
Published on 2011-01-13T18:58:59Z
Indexed on
2011/01/14
0:53 UTC
Read the original article
Hit count: 118
Hello. I have a file input in a form that uploads a mp3 file, but I´d like to detect conflictive characters to my system in the filename, like ! @ or any other.
All codes I´ve found replace these characters, but I just want to detect them to alert the user. I think it will be easy with regular expressions, but I dont know about them.
I´m using jquery/javascript.
Thanks in advance for your help
Edit to improve my problem description:
I´m working in a CodeIgniter application that allows user to upload mp3 files to the server. I use jQuery to manage client side forms. The CI upload class converts spaces in the file name to underscores and everything works. But testing the application I uploaded a mp3 file with a (!) in the name, and I got troubles with it.
I just want to insert a javascript conditional before the file is uploaded to evaluate if the user´s filename contains a (!) (or any other I´d like to add later) to ask for the file to be renamed if it does.
© Stack Overflow or respective owner