-
Notifications
You must be signed in to change notification settings - Fork 1
Helper Functions
tomolimo edited this page Nov 23, 2021
·
9 revisions
Some helper functions can be used in Formulas to ease field validations:
They have been added via a namespace: FVH
-
FVH.isValidDate(d, t = false)
:d
is a string which can be a date or a datetime.t
is a boolean which if true will validate a datetime or false will validate a date only. The date format is retrieved from GLPI user profile. Returns true ifd
is a valid date, false otherwise. To be used with datepicker fields for example. Beware that ifd
is an empty string''
it will return true: empty string must be tested by a#!=''
for example. -
FVH.isValidTime(s)
: returns true ifs
is a valid time, false otherwise. -
FVH.isValidInteger(i)
: returns true ifi
is a valid integer, false otherwise. If value is an empty string then returns false. -
FVH.countWords(s)
: returns the quantity of words ins
. There is no condition on the size of each words. -
FVH.isValidIPv4(s)
: returns true ifs
is a valid IP V4 address, false otherwise -
FVH.isValidIPv6(s)
: returns true ifs
is a valid IP V6 address, false otherwise -
FVH.isValidMacAddress(s)
: returns true ifs
is a valid MAC address, false otherwise -
FVH.isValidEmail(s)
: returns true ifs
is a valid email address, false otherwise. Will use theinput type=email
if it exists (HTML5), otherwise will use a basic verification. Anyway, will verify that email address is valid, the check is only about format.
If you need more helper functions, please post an issue explaining your needs: https://github.com/tomolimo/formvalidation/issues