Preceding and trailing spaces are ignored with text input

All,

It appears that preceding spaces or trailing spaces are ignored in a text input.
This becomes an issue when we do a 'password entry'
There is also no trigger on the output when a space is entered.

Example code

[{"id":"de2de0af.b6406","type":"ui_text_input","z":"37e2c67c.85274a","name":"","label":"","tooltip":"","group":"668d9db5.aab0e4","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":"100","topic":"","x":340,"y":280,"wires":[["17f4886.d747c78"]]},{"id":"9dbeea4a.9fd778","type":"ui_text_input","z":"37e2c67c.85274a","name":"","label":"","tooltip":"","group":"668d9db5.aab0e4","order":1,"width":0,"height":0,"passthru":true,"mode":"password","delay":"100","topic":"","x":360,"y":330,"wires":[["e86ed49d.f07ec8"]]},{"id":"17f4886.d747c78","type":"debug","z":"37e2c67c.85274a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":640,"y":280,"wires":[]},{"id":"e86ed49d.f07ec8","type":"debug","z":"37e2c67c.85274a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":640,"y":330,"wires":[]},{"id":"668d9db5.aab0e4","type":"ui_group","name":"Group 1","tab":"1cec7880.5a4688","order":1,"disp":true,"width":6},{"id":"1cec7880.5a4688","type":"ui_tab","z":"","name":"Example entry","icon":"dashboard","order":7,"disabled":false,"hidden":false}]

image

As you can see in above example, we entered the following
' 3 spaces ' (Not the '')

But the payload out of the function is in both cases

{"payload":"3 spaces","socketid":"XrYwAW7CPErPnN2WAAAJ","_msgid":"434e6646.6207c8"}

any spaces between characters are captured.
This causes me grief as I use the password entry and compare this with a fixed entry.
The user thinks he entered 14 characters, but the payload only presents 8 characters.

If the entry is made only out of spaces, then no payload is delivered out of the text input function

Any way to get around this?

Advise users not to use spaces ?

:joy:... but seriously, if the input is trimming whitespace by default, it does feel like there should be an option to not do that. It isn't for us to decide what is valid input or not.

Dceejay,

Same method as telling people not to push a button. They will anyway, so as a coder we need to prevent 'stupidity' so the suggestion is nice, but the practicality does not work.

Thanks for your feedback though

@knolleary

Agree, an option 'tick' box would be great

PR very welcome

@dceejay

I am sorry, I am not a person that talks abbreviations so do not comprehend your comment.
PR = Public Relations??

Will have a look if I can decipher the original code and see where I can fix this.

Any guidance will be appreciated as my JS (java script) knowledge is well below your level

Thanks

Have you thought about using the ui-form's 'password' type?

So it turns out that this is the default behaviour of angular-material text input boxes... they perform a trim() of any input. There is an optional parameter that can be added to the input tag ng-trim="false" that turns that off.

I guess the next question is do we really need it optional ? should not-trimmed just be the way it should be (as was expected) ?

PS : PR = Pull Request - a fix to the code submitted by someone.

I agree, any non intentional (happening behind the scenes) data manipulation is confusing. And who knows there will be a time where passwords could be a little poem and totally valid - and the white spaces in dada poems count.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.