Categories:
Cloud (204)
Entertainment (11)
Facebook (43)
General (50)
Life (31)
Programming (64)
Technology (398)
Testing (4)
Tools (488)
Twitter (5)
Wearable (26)
Web Design (44)
Collections:
Other Resources:
Add JavaScript Validation Function
How to Add JavaScript Validation Function?
✍: FYIcenter.com
After creating a new field type, you may want to add your own custom validatino rule
through a new JavaScript function.
1. Go back to "Modules > Custom Fields" and edit "My Int" field type.
2. Click "Validation" tab. You see a list of validation rules inherited from "textbox" field type.
3. Click "Add Validatin Rule". You see a the "Add Validatin Rule" page.
4. Select "Custom > Function" as the validation rule type. And the following:
Label: Two-digit numbers Default Error Message: Your number is out of range. Custom Function: cf_int.two_digits Is this a required field: Yes
3. Click "Displaying > JavaScript" type and enter the follow JavaScript code to define the validation function:
var cf_int = {}; cf_int.two_digits = function() { var errors = []; for (var i=0; i<rsv_custom_func_errors.length; i++) { if (rsv_custom_func_errors[i].func != "cf_int.two_digits") { continue; } var field_name = rsv_custom_func_errors[i].field; var fields = $("input[name^=\"" + field_name + "\"]"); var field_value = fields.val(); if (field_value<0 || field_value >99) { var el = document.edit_submission_form[field_name]; errors.push([el, rsv_custom_func_errors[i].err]); } } if (errors.length) { return errors; } return true; }
Now "My Int" field type supports a new custom validation rule called "Two-digit numbers"
See the next tutorial on how to use this validation rule.
Â
⇒ Use Custom Field with Custom Validation
⇠Create "My Int" Field Type
2019-12-02, 1028🔥, 0💬
Popular Posts:
How to download publication files from libgen.rs? libgen.rs or gen.lib.rus.ec is the most robust Web...
How to install Mozilla Firefox 2.0 add-on: FireFTP? FireFTP is a Mozilla Firefox 2 add-on that provi...
Why am I getting the "Spawn Failed: Server at http://127.0.0.1:47353/u ser/fyicenter/didn't respond ...
What is "OneNote Linked Notes Add-in" in Microsoft Word? Should I disable it? "OneNote Linked Notes ...
How register my Fitbit device through Fitbit Connect? I have an account with Fitbit server, installe...