Changes

Jump to: navigation, search

JavaScript Validation

536 bytes added, 14:52, 9 July 2021
To limit the amount of characters that can be entered into a field
The JavaScript syntax can be entered into the ''JavaScript Validation'' field on the custom field settings page.
 
If '''SmartCheck''' is enabled, every reference to "frm.cf_''fieldid''.value" should be changed to;
form.getStr("cf_fieldid")
==To accept only certain values==
==To limit the amount of characters that can be entered into a field==
 
@value@.length<''n''
@value@.length<35
 
==To validate the length of a number entered into a field==
@value@.toString().length==n
 
'''Where'''
 
''n'' is any number
 
'''Example'''
 
To see if the length of a number is 10
 
@value@.toString().length==10
==To have a custom field only accept values in a range==
parseInt(@value@)==@value@
 
==To restrict a special character or a string==
 
@value@.indexOf("enteryourstringhere")==-1
==To check if a phone number of a certain format==
frm.cf_@Project Budget.id@.value>=@value@
 
If SmartCheck is enabled, use the following instead;
form.getStr("cf_@Project Budget.id@") >= @ value@
If you wish to make a field mandatory ''only if'' the value ''Yes'' is selected from a dropdown field, for example, use:
@value@!=="" || frm.cf_''fieldid''.value!="Yes"
in the JavaScript validation setting where:
2
edits

Navigation menu