Difference between revisions of "JavaScript Validation"
Julia Decker (talk | contribs) |
Julia Decker (talk | contribs) |
||
Line 9: | Line 9: | ||
If @value@ is not found, the system will automatically put it at the very front of the validation criteria. | If @value@ is not found, the system will automatically put it at the very front of the validation criteria. | ||
− | Where | + | '''Where''' |
n is any number | n is any number | ||
Line 23: | Line 23: | ||
== means equal to | == means equal to | ||
− | Example | + | '''Example''' |
To have a [[Custom Fields|custom field]] only accept values larger than 100, enter | To have a [[Custom Fields|custom field]] only accept values larger than 100, enter | ||
Line 33: | Line 33: | ||
@value@.length<n | @value@.length<n | ||
− | Where | + | '''Where''' |
n is any number | n is any number | ||
− | Example | + | '''Example''' |
To limit the number of characters in a field to 35 or less | To limit the number of characters in a field to 35 or less | ||
Line 47: | Line 47: | ||
@value@>n && @value@<n | @value@>n && @value@<n | ||
− | Where | + | '''Where''' |
n is any number | n is any number | ||
Line 59: | Line 59: | ||
() means brackets :-) | () means brackets :-) | ||
− | Example | + | '''Example''' |
− | To have a custom field only accept values between 100 and 200, enter | + | To have a [[Custom Fields|custom field]] only accept values between 100 and 200, enter |
" @value@>99 && @value@<201 " | " @value@>99 && @value@<201 " | ||
Line 77: | Line 77: | ||
A = Alphanumeric | A = Alphanumeric | ||
− | AND | + | '''AND''' |
isEmptyOK is | isEmptyOK is | ||
Line 83: | Line 83: | ||
True or False | True or False | ||
− | Example | + | '''Example''' |
To validate 9 digits SIN number, put this into the box | To validate 9 digits SIN number, put this into the box | ||
Line 93: | Line 93: | ||
isFloat(@value@.replace(/c/g,""),true) | isFloat(@value@.replace(/c/g,""),true) | ||
− | where | + | '''where''' |
c is any character | c is any character | ||
− | Example | + | '''Example''' |
To allow a field to only hold numbers and a semi-colon | To allow a field to only hold numbers and a semi-colon |
Revision as of 11:37, 26 October 2007
Contents
Validation Options
Other than Numeric, Alphabetic, Date and Allow Empty, users can define their own validation or criteria for a custom field by creating a user-defined validation based on JavaScript syntax.
To have a custom field only accept certain values
>n or @value@>n
If @value@ is not found, the system will automatically put it at the very front of the validation criteria.
Where
n is any number
> means greater than
< means less than
>= means greater than or equal to
<= means less than or equal to
== means equal to
Example
To have a custom field only accept values larger than 100, enter
>100 or @value@>100 in the Custom box.
To limit the amount of characters that can be entered into a field
@value@.length<n
Where
n is any number
Example
To limit the number of characters in a field to 35 or less
@value@.length<35
To have a custom field only accept values in a range
@value@>n && @value@<n
Where
n is any number
&& means "AND"
|| means "OR"
! means "Not"
() means brackets :-)
Example
To have a custom field only accept values between 100 and 200, enter
" @value@>99 && @value@<201 "
To perform pattern matching
isMatch(@value@, pattern, isEmptyOK)
Where pattern is
L = Letter
N = Number
A = Alphanumeric
AND
isEmptyOK is
True or False
Example
To validate 9 digits SIN number, put this into the box
isMatch(@value@, 'NNNNNNNNN', false)
To allow only numbers and one other character
isFloat(@value@.replace(/c/g,""),true)
where
c is any character
Example
To allow a field to only hold numbers and a semi-colon
isFloat(@value@.replace(/;/g,""),true)