There's something I've been pondering that pertains to MVC platforms, but could also be relevant to any web-based platform that deals with user input forms.
When is the best time and method to eliminate leading/trailing whitespace from user input?
I can see a few potential stages for this process:
- Immediately upon receiving user form input - using JavaScript functions to remove spaces as they type or before submission
- Within the Controller when processing parameters
- Using intermediate model/attribute methods
- Prior to or during database storage
What is considered best practice in this scenario, and what are the advantages and disadvantages of each stage, if there are multiple options?)