Forum Moderators: open

Message Too Old, No Replies

Trimming Form Values

After form submission

         

jnscollier

11:28 pm on Jun 8, 2006 (gmt 0)

10+ Year Member



I am trying to trim the values of a form submission on my action page. I used a form using the get method to pass the values. Now the values show with a space before and after all fields submitted on the action page...

IS there a way to remove these? Possibly trim them on the action page itself?

(((((((Sammy))))))))))

adni18

12:37 am on Jun 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, you can do this in PHP and Perl, and probably in ASP/cfm. Which server-side thing are you using? Also, test this in other browsers. It might be a browser-specific problem.

jshanman

12:50 pm on Jun 9, 2006 (gmt 0)

10+ Year Member



you could use regular expressions in Javascript to validate the users entry before submitting the information.

Then use server side code to validate the submission for security reasons...

var s = "(((((((Sammy))))))))))";
s = s.replace(/[^a-z0-9]/ig,"");

This regular expression will remove any character that is not alpha (a-z) or numeric (0-9). The "i" makes the search case insensitive. The "g" makes the replace global.

- JS

jnscollier

3:02 pm on Jun 9, 2006 (gmt 0)

10+ Year Member



Awesome code.. but I obviously shouldnt pass the variables through the URL bc I think that's my problem. I'm just going to have to redo my form and pass it via javascript... I was avoiding that. Instead i just used an action page with a get method. And I guess that passes it with a leading and ending space... And then when I try to pass a value from the action page to another page the url looks like: www.blah.com/+username+... instead of www.blah.com/username.

Thx though you guys! :) **sammy**