...
Code Block |
---|
var CustomEventHandlers = { setup: function (el) { if (CustomView.hasClass(el, 'SSN')) { FEvent.observe(el, 'keydown', this.formatSSN.bindAsObserver(this, el)); FEvent.observe(el, 'keyup', this.formatSSN.bindAsObserver(this, el)); } }, formatSSN: function (event, element) { if (event.keyCode != 46 && event.keyCode != 8) { fldVal = $(element).value; var nom = fldVal.charAt(fldVal.length - 1); if (isNaN(nom) && nom != "-") { $(element).value = fldVal.substring(0, fldVal.length - 1); } else { if ((fldVal.length == 3) || (fldVal.length == 6)) { $(element).value = fldVal + "-"; } if (fldVal.length >= 11) { $(element).value = fldVal.substring(0, fldVal.length - 1); } } } } } |
Correct the case of any text
...
Code Block |
---|
var CustomEventHandlers = { setup: function (el) { if (CustomView.hasClass(el, 'limit3')) { FEvent.observe(el, 'click', this.checkboxlimit.bindAsObserver(this, el)); } }, checkboxlimit: function (evt, el) { var checkgroup = el.childrenWithClassName('input'); var limit = 3; for (var i = 0; i < checkgroup.length; i++) { checkgroup[i].onclick = function () { var checkedcount = 0 for (var i = 0; i < checkgroup.length; i++) checkedcount += (checkgroup[i].checked) ? 1 : 0 if (checkedcount > limit) { this.checked = false for (var i = 0; i < checkgroup.length; i++) (checkgroup[i].checked) ? checkgroup[i].disabled = false : checkgroup[i].disabled = true; } else { for (var i = 0; i < checkgroup.length; i++) checkgroup[i].disabled = false; } } } } } |
Scroll to Top
A Tab control with many fields in each tab, may require a long scroll to switch from one tab to another. You can use a trigger control at the bottom of the first tab with a business rule to navigate the user to the second tab when the trigger is clicked. For example, when you click on the Next Tab trigger control on the Personal Information tab in the Application for Employment form shown a business rule will navigate the user to the Employment History tab.
...
Code Block |
---|
var CustomEventHandlers = { uploadEl: null, setup: function (el) { if (CustomView.hasClass(el, 'onlyPDF')) { this.uploadEl = el; } window.setTimeout('CustomEventHandlers.checkFile()', 3000); // set the initial timer }, checkFile: function () { for (var i = 0; i < this.uploadEl.parentNode.childrenWithClassName('f-file-upload-file-name').length; i++) { if (!(/^.*\.(pdf|PDF)$/.test(this.uploadEl.parentNode.childrenWithClassName('f-file-upload-file-name')[i].getAttribute('title')))) { alert("Invalid file '" + this.uploadEl.parentNode.childrenWithClassName('f-file-upload-file-name')[i].getAttribute('title') + "' will be removed."); this.uploadEl.parentNode.childrenWithClassName('f-upload-file-list-delete')[i].click(); } } window.setTimeout('CustomEventHandlers.checkFile()', 3000); } } |
...
Automatically submit a form
...
This JavaScript example will submit the form upon when the user pressing presses the Enter key.
Code Block |
---|
if (document.layers) { document.captureEvents(Event.KEYPRESS); } document.onkeypress = function (evt) { var keyCode = evt ? evt.which : event.keyCode; if (keyCode == 13) { SubmitView.doSubmit("Submit"); } else { return true; } }; |
...