Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strip Spaces not working 1

Status
Not open for further replies.

kelly5518

Technical User
Aug 1, 2005
72
US
Hi,

Quite a while back some nice person on this forum gave me the following script to prevent someone entering spaces in a form field that's required. It seems to work fine for me when I fill in the field with spaces and click submit, it gives the error message saying to fill in the required field.

But for some reason I'm getting emails coming through where nothing is filled in and I can't figure out why. Here's what I have:
Code:
function stripSpaces(frm) {
    var x = frm.name.value;
    frm.name.value = (x.replace(/^\W+/,'')).replace(/\W+$/,'');
    var z = frm.avail.value;
    frm.avail.value = (z.replace(/^\W+/,'')).replace(/\W+$/,'');
    redirect(frm);
   }
Note: (redirect(frm) is another function that determines the action tag based on user input)

Thanks for any suggestions.
 
Maybe your users have javascript turned off? You'll have to check server side as well as client side to ensure these people don't slip thru the cracks.

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
Hmmm, why didn't I think of that! :-\

I'll look into doing some form validation server side.

Thanks
 
Got it done. Thanks for rattling my brain a little kaht. :)
 
[thumbsup2] no problem.

Hope that turned out to be the bandit. Pretty easy fix if so.

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
Well, I guess that wasn't the problem after all. I'm still getting empty posts even though I have server-side validation as well as javascript validation.

Does this mean it's some sort of hack?

Thanks for all suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top