I'm finding that some of my script logic is failing when an end-user happens to deposit some whitespace into an optional input field. In other words, if the user hits the space bar while an input field has the cursor, then moves on, it is no longer a null field, and my scripts will expect data to be there (but the data is whitespace).
What is the most straightforward way to trim whitespace (or eliminate a string that's nothing but space) from any and all input fields? Thanks for reading.
Solved! Go to Solution.
Views
Replies
Total Likes
Simple way is to add the following javascript to the exit: event of the input field:
this.rawValue
= this.rawValue.replace(/^\s+|\s+$/g,"");
Whenever a user fills in and leaves the field it will trim the spaces (you will see this happen on the screen).
Views
Replies
Total Likes
Simple way is to add the following javascript to the exit: event of the input field:
this.rawValue
= this.rawValue.replace(/^\s+|\s+$/g,"");
Whenever a user fills in and leaves the field it will trim the spaces (you will see this happen on the screen).
Views
Replies
Total Likes
Works perfectly, and great insight into a function I did not know existed. Thanks.
Views
Replies
Total Likes