Midwest Dev Chat

MidwestDevChat.com

  • The newest 15 messages in the super-cool #angularjs channel.

  • 04/04 13:18:00 Remona: ok, I'm having an issue with angular 2 pattern validitor
  • 04/04 13:19:05 Remona: it's always returning invalid, even though I know the regex works
  • 04/04 13:40:48 Remona: nevermind, angular is a jerk. it says you can pass a regex as a string to a validator, but that's a lie.
  • 04/10 16:04:32 Marilyn: yo @Remona et al. You guys have a good way to handle trailing and starting whitespace in form fields?
  • 04/10 16:05:08 Marilyn: Looking for best use - directive, trim on submit, validation, etc. Thoughts?
  • 04/10 16:07:26 Remona: hrmm, depends on the use case
  • 04/10 16:07:45 Remona: I would PROBABLY trim on submit, if it's something the user shouldn't be aware of
  • 04/10 16:08:06 Ethan: For any simple, client-knowable changes like whitespace, I like to fix it in the input right after the user is done with the field
  • 04/10 16:10:09 Ethan: But if you have a lot of validation/data-fixing code (especially if your server uses a language other than JS and you can't share validation/data-fixing code), it may be easiest to just submit the form at the server, let it change anything, and then send you back the canonical/fixed version to update the view with (assuming the client app hasn't navigated away)
  • 04/10 16:10:58 Ethan: In business apps I like to combine the two by saving each field on every `change` event :-x
  • 04/10 16:11:53 Ethan: Confusingly, the browser `change` event is different from `ng-change`...
  • 04/11 08:31:16 Boyd: I concur. `change` event is a good way to let the client know you've trimmed the field. Doing it on `submit` is a good way to do it when the client doesn't need to know or shouldn't know.
  • 04/12 10:54:33 Marilyn: Thanks @Remona @Ethan and @Boyd. I ended up using a pattern validator to check for beginning spaces. If I checked for trailing whitespace, it gets flagged all the time since a person may be named something like 'Billie Jean' or some other two-word name. Then I just trimmed on submit.
  • *Usernames have been changed to protect the innocent.
We're currently 1048 members strong. Join us!
Request Invite

Check out all the cool channels!

Join the conversation!