Author Topic: What is the proper way to deal with input validation?  (Read 3833 times)

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
What is the proper way to deal with input validation?
« on: February 16, 2013, 11:14:52 PM »
I've been putting this off for a while, but I can't seem to find a way to do input validation when typing in text.  For example, what if I only want the player to be able to type 10 characters for a name?  or only A-Z characters (no numbers, or special character).  I was expecting NGUI to have a native solution to this, but can't find it.

What is the proper way to handle this type of validation? 
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: What is the proper way to deal with input validation?
« Reply #1 on: February 17, 2013, 05:12:17 AM »
Can't find it? Serious?

UIInput.maxChars
UIInput.validator

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: What is the proper way to deal with input validation?
« Reply #2 on: February 17, 2013, 01:38:43 PM »
I  guess I was focusing on the label component, and not the parent.  Silly me.  Thanks for the links.

There's almost no documentation on UIInput.validation, though.  I would say that it's a good idea to state in the doc notes that it's a component of it's own that you are required to add.
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: What is the proper way to deal with input validation?
« Reply #3 on: February 17, 2013, 07:09:23 PM »
Take a look inside UIInputValidator.