Can we restrict spaces to be enter in a field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2016 10:07 AM
Can we restrict spaces to be enter in a field?
Regards,
Lrr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2016 10:11 AM
Hi Lrr,
Yes you can with the use of regular expressions. You could write an onChange client script on the field in question. (Untested code ahead)
- function onChange(control, oldValue, newValue, isLoading, isTemplate) {
- if (isLoading || newValue === '') {
- return;
- }
- var regex = new RegExp("^[a-zA-Z0-9]*$");
- if(!regex.test(newValue)){
- alert('Incorrect field value. Please don't enter spaces');
- g_form.setValue('ur_field_here','');
- }
- }
This will only allow lower and upper case letters and numbers. You could add special characters too in the regex if you want to allow them as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 01:49 AM
Thanks veena.
It is working.
But the problem is 'It is not allowing the description with spaces'.
Thanks,
Lrr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 02:05 AM
Use trim() function to remove spaces.
trim(newValue)
How can we make the field read only when it contains the data?
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 03:06 AM
I used before insert/update Business rule with the below.
(function executeRule(current, previous /*null when async*/) {
var des = current.description.trim();
if(des == '')
{
gs.addErrorMessage("Description can not be null");
current.setAbortAction(true);
}
})(current, previous);
Now it is working
Thanks,
Y Anjaneyulu