Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Disastercake on February 16, 2013, 11:14:52 PM

Title: What is the proper way to deal with input validation?
Post by: Disastercake 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? 
Title: Re: What is the proper way to deal with input validation?
Post by: ArenMook on February 17, 2013, 05:12:17 AM
Can't find it? Serious?

UIInput.maxChars (http://www.tasharen.com/ngui/docs/class_u_i_input.html#a8fa80c3cfe8ecbc79f6f50e0b9457465)
UIInput.validator (http://www.tasharen.com/ngui/docs/class_u_i_input.html#aaeee199d0fb1212639e1859f821f676e)
Title: Re: What is the proper way to deal with input validation?
Post by: Disastercake 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.
Title: Re: What is the proper way to deal with input validation?
Post by: ArenMook on February 17, 2013, 07:09:23 PM
Take a look inside UIInputValidator.