Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

Validation in BlackBerry10

[ Edited ]

I am trying to develop one app in which I need one registration page.  How should I apply validation in that for phone numbers and e-mail ?   I tried this by using  

 

inputMode: TextFieldInputMode.EmailAddress

 

 for e mail address but it's not working properly

 

   Please help me.

Developer
Posts: 232
Registered: ‎01-30-2011
My Device: Dev Alpha C, Z10 LE
My Carrier: P4

Re: Validation in BlackBerry10


dhirajnangare wrote:

 

inputMode: TextFieldInputMode.EmailAddress

It don't work, because that property specifies the type of keyboard that is displayed on touch screen devices.

 

 

 

Try this validator or check TextField value onSubmitted:

input {
    onSubmitted: {
        //...Perform action on submission...
    }
}

 

All time online Smiley Very Happy
Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

Re: Validation in BlackBerry10

I didn't get your answer . would you please explain it 

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Validation in BlackBerry10

Specifying the input mode will only control which virtual keyboard is presented to the user. It doesn't actually prevent them from entering other characters (either on a device with a physical keyboard like the Q10, or if they have a bluetooth keyboard connected).

 

If you want to validiate a user's input, use the validator API (https://developer.blackberry.com/native/reference/cascades/bb__cascades__validator.html) as 26filip suggested. You will have to come up with your own expression that validates a phone number and emai.

 

Do you really need to validate it though? There is nothing stopping a user from entering a valid phone number or email that doesn't belong to them. Coming up with a perfect regular expression that lets in only valid phone numbers or emails and doesn't also block valid ones is extremely difficult.

 

I wouldn't bother with anything more than a basic sanity check (does it have a '@' followed sometime by a '.'? Ok, we're good to go).

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker