...
You have an upload control in your form and you want to limit the type of documents allowed to PDF only. Use the following JavaScript to validate if the uploaded document has a .PDF pdf extension, and remove it if it doesn’t. An error message "Invalid File "filename" will be removed" will display to it doesn't. Add onlyPDF to the CSS Class property of your Upload control to enable this JavaScript.
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); } } |
Add onlyPDF to the CSS Class property of your Upload control to enable this JavaScript.
Automatically submit a form
This JavaScript allows the user to bypass a form when it is not required. For example: A user fills in Form A as a new customer registration Form (A) and is normally forwarded to Forms B and C to complete the task. It is possible Users that users that are not registering for the first time, might skip Form B and go directly to form C. You can use following JavaScript to automatically submit a form when a control in the form contains some specific value (say “not-new”) in it.
...
You can use the following JavaScript to display an extra submit button at any position on your form. Add a trigger control to your form and set auto-submit in its the CSS Class property. Now you can use this trigger control as your Submit button and place it anywhere on your form.
...
Add onlyDigits in the CSS Class property of the Quantity control. This script will automatically remove a decimal points from point from the field and the error message will not display. Similar logic can be used to implement instant validation on other control types as well.
...