Jump to content

using trim


jimfog

Recommended Posts

Do you think that when I validate form with js I should use trim() for removing the whitespace

or I should leave this entirely on server-side code?

Link to comment
Share on other sites

I think both are needed.

Link to comment
Share on other sites

  • 2 weeks later...

any comment on the above?

Link to comment
Share on other sites

It depends on the requirements for your site, do what works for your site. If you need to trim the data before you validate in Javascript, then trim it.

Well...the issue here is I DO NOT know if my site would require such functionality.

I intend using trim in a form where the user can edit its profile...name,phone,e-mail etc...

It is a pretty standard type of form I think.

What I should do?I intend using trim.

 

Is there any argument NOT to use it from the description I gave above?

Link to comment
Share on other sites

 

 

the issue here is I DO NOT know if my site would require such functionality

But you think I do?

 

Here's the basic idea: if trimming the data would affect form validation, then trim it. If it's not going to affect validation then it doesn't matter.

Link to comment
Share on other sites

But you think I do?

 

Here's the basic idea: if trimming the data would affect form validation, then trim it. If it's not going to affect validation then it doesn't matter.

Of course I do not expect from you to know the requirements of my application.

I was asking just to know if there is a standard approach used by developers in this matter.

Link to comment
Share on other sites

It is much better to keep garbage out of a database than to try to get it out later. Trim is something that is easily done with hardly any effort at all and is probably needed to validate anyway.

Link to comment
Share on other sites

 

 

Of course I do not expect from you to know the requirements of my application.I was asking just to know if there is a standard approach used by developers in this matter.

I understand, I'm just trying to get you to think about whether or not its needed. There's not a standard that everyone uses for things like validation or whether or not to use ajax with a contact form, those kinds of decisions are yours to make based on your requirements for the application. You ask questions like that from time to time where I think the best answer is for you to pick the one that makes sense to you, implement it, and use it for a while to see if it works. If it didn't work, then you learn something.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...