Hi Alexandre. On 3/8/07, Alexandre Plennevaux <[EMAIL PROTECTED]> wrote: > Hi Sean, > > I indeed did it via regular expressions:)
Good, but you shouldn't rely on stripping a list of invalid characters. It's safer to strip any character that doesn't belong to a whitelist. This code "ínó".replace(/[^a-z0-9]/ig, ""); will delete from the string any characters that are not in the ranges a-z or 0-9. Your aproach would allow the user to insert (c)∫∂æ†∑Ω crappy characters :( Anyway, don't forget to replicate the validation on the server side. > Here is the final code: > > $("input#title").keyup(function(){ > var oldVal = $(this).val(); > oldVal = oldVal.toLowerCase(); > newFolder = oldVal.replace(/^\s+|\s+$/g,"").replace(/[ > _:&;\"']/g,"-").replace(/[*'²"+!?\/@°\]\[<>]/g,"").replace(/[éèë]/g,"e").replace(/[ï]/g,"i").replace(/[äà]/g,"a").replace(/[ùûü]/g,"u"); > $("input#project_folder").val(newFolder); > > }); > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sean O > Sent: jeudi 8 mars 2007 18:37 > To: discuss@jquery.com > Subject: Re: [jQuery] generate folder name > > > Alexandre, > > > You should be able to simply test the folder name string against a regular > expression. > > More info: > http://www.regular-expressions.info/javascript.html > http://www.websina.com/bugzero/kb/regexp.html > > > HTH, > > ________ > SEAN O > http://www.sean-o.com > > > > Alexandre Plennevaux wrote: > > > > hello! > > > > i am creating a form where user enters the name of a new project. > > First field is "title", the second one is "project folder name". > > I would like to proposed a failsafe folder name from the project title. > > Can somebody provide me with a good idea on how to generate a secure > > folder name out of any string input, thus removing all non > > alphanumeric characters ? > > > > > > Thank you!! > > > > Alexandre > > -- Choan <http://choangalvez.nom.es/> _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/