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 ? Please somebody help me
Asked
Active
Viewed 132 times
0
-
So you want to check username and password from a server or check if phone number and email are valid format? – Bojan Kogoj Oct 29 '13 at 09:19
1 Answers
2
You can place validation in your TextFields as follows:
TextField {
id: myTextField
hintText: "Flight number"
inputMode: TextFieldInputMode.NumbersAndPunctuation
validator: Validator {
mode: ValidationMode.Immediate
errorMessage: "Please enter only numbers for this field"
onValidate: {
var valNumeric = /^[0-9 -]+$/i; //Numbers, including space and minus/dash
if (valNumberic.test(parent.text)) {
state = ValidationState.Valid;
} else {
state = ValidationState.Invalid;
}
}
}
}
You can set the inputMode to something such as NumbersAndPunctuation or Email and that will affect the keyboard. Then in the onValidate you can compare the parent.text with a regex expression or in any other way you wish. Setting ValidationState to Invalid will show a validation error with the message you specify in errorMessage.

hyarion
- 2,251
- 2
- 17
- 28