Search.../

validations

Sets or gets the validations for mobile elements in a form.

Description

Setting the validations property sets the validations for mobile elements in a form.

Getting the validations property returns the current list of validation objects for mobile elements in a form.

Each validation object contains a validationType and a validation message.

Type:

Array<Validation>Read & Write
NAME
TYPE
DESCRIPTION
validationType
string

The validation type. Supported values:

  • 'required'
  • 'url'
  • 'numeric'
  • 'wholeNumber'
  • 'decimalNumber'
message
string

The validation message.

Was this helpful?

Set the mobile element's validations

Copy Code
1$w('#mobileTextInput1').validations = [
2 { validationType: 'required', message: 'This field is required.' },
3 { validationType: 'url', message: 'Not a valid URL.' }
4];
Get the mobile element's validations

Copy Code
1let myMobileTextInputValidation = $w('#mobileTextInput1').validations; // [{ validationType: 'required', message: 'This field is required.' }, { validationType: 'url', message: 'Not a valid URL.' }]