Changes

JavaScript Validation

946 bytes added, 14:52, 9 July 2021
To limit the amount of characters that can be entered into a field
{| class="wikitable"
|-
|[[Image:How.png|50px|link=]]
|This article will explain '''how''' you can implement this feature for use on your SmartSimple system.
|}
 
{{JavaScript Syntax}}
__TOC__
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:
* [[Maximum Length]]
{| class="wikitable"|-|[[Image:Why.jpeg|50px|link=]]|Click [http://wiki.smartsimple.com/wiki/Updated_Functionality_for_Maximum_Word/_Character_Limit_-_Why%3F here] to learn why this feature is a benefit to your organization.|} [[Category:Custom Fields]][[Category:JavaScript]][[Category:Validation]][[Category:How]]
2
edits