How can I restrict the type of data users enter into my form fields?

Is there a way to make sure people enter date data or numeric data, etc into a form field?


Tony DeYoung


3 Answers

To restrict the format for a text field, open its properties.
Click the Format tab and select the format category.
Then select the option that is appropriate for your field.


Lori Kassuba   

For advanced data validation you can also use the Validate tab of the properties window, which offers a range validation (if you selected the Number format), or you can write you own (JS) code to determine whether the entered value should be accepted or not.


Gilad D (try67)   

Another JavaScript-based approach is to make the field ignore certain characters. You would do this directly in the Keystroke Event, such as in this example which allows entering only numbers, the period (as decimal sign) and the hyphen (as minus sign), and it also allows to delete characters:

if (!event.willCommit && event.change.length > 0) {

event.change = event.change.replace(/[^0-9\.-]/,"") ;

}


Note that this still would allow entering illegal numbers, such as "223.53-391.33". However, if your process has item numbers which may be formed like this, you would be spot-on with this example.



Max Wyss   


Please specify a reason: