Wijmo UI for the Web
Validation Function Library
Wijmo User Guide > Concepts > Validation Function Library

Wijmo provides a validation function library that allows you to use string parsing and validation functions outside of the input widgets, so that you can have matching input and output routines. Wijmo provides four types of validation functions: Text, Mask, Date, and Number. Each function has a value parameter, plus other optional parameters. See each type below for further details.

Text Validation

Text validation comes in two flavors. The first takes only two parameters, value and format, and the other takes three, value, minLength, and maxLength. In either case, if the value cannot be parsed as the specified type, the function returns false.

bool $.wijinputcore.validateText(string value, string format);  
bool $.wijinputcore.validateText(string value, Number minLength, Number maxLength);

Drop down to view parameter details and code examples

Parameter Name Type Description
value string The value to validate.
format string The formatting string to use in validating the value.
For the full list of supported format keywords, see Text Format Keywords.
minLength Number The minumum number of characters to accept as valid input.
maxLength Number The maximum number of characters to accept as valid input.

Examples

Text Validation Examples
Copy Code
$.wijinputcore.validateText("123", "9");
 //returns: true
$.wijinputcore.validateText("あ山9", "Z");
 //returns: true
$.wijinputcore.validateText("9999999", 4, 7);
 //returns: true

Mask Validation

Mask validation takes two parameters and returns a Boolean value. If the value cannot be parsed with the specified format, the function returns false.

bool $.wijinputcore.validateMask(string value, string format);

Drop down to view parameter details and code examples

Parameter Name Type Description
value string The value to validate.
format string The formatting string to use in validating the value.
For the full list of supported format keywords, see Mask Format Keywords.

Example

Mask Validation Example
Copy Code
$.wijinputcore.validateMask("1234567", "999-9999");
 //returns: false

Number Validation

Number formatting takes four parameters. Only the value parameter is required. If the value cannot be parsed with the specified parameters, the function returns false.

bool $.wijinputcore.validateNumber(string value, Number minValue, Number maxValue, string culture);

Drop down to view parameter details and code examples

Parameter Name Type Description
value string The value to validate.
minValue Number The lowest number to accept as a valid value.
maxValue Number The highest number to accept as a valid value.
culture string The culture to use in validating the value. (Some cultures use a comma as a decimal marker.)

Examples

Number Validation Example
Copy Code
$.wijinputcore.validateNumber("123,45.6", 100, 100000);  
 //returns: true

Date Validation

Date validation takes five parameters. Only the value parameter is required. If the value cannot be parsed with the specified parameters, the function returns false.

bool $.wijinputcore.validateDate(string value, Date minDate, Date maxDate, string format, string culture);

Drop down to view parameter details and code examples

Parameter Name Type Description
value string The value to format.
minDate Date The earliest date to accept as a valid value.
maxDate Date The latest date to accept as a valid value.
format string The formatting string to use in validating the value.
For the full list of supported format keywords, see Date Format Keywords.
culture string The culture to use in validating the date.

Examples

Date Validation Examples
Copy Code
$.wijinputcore.validateDate("12/3/2012", new Date(2013,0,1), new Date(2013,11,31));   
 //returns: false
$.wijinputcore.validateDate("平成 25年12月16日", new Date(2013,0,1), new Date(2013,11,31), "ggg ee年MM月dd日");  
 //returns: false
See Also

Reference