Skip to content

Commit 31a9ecd

Browse files
WhiteSpace Validation (ServiceNowDevProgram#1474)
1 parent a6ae81d commit 31a9ecd

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This Client Script will validate whether the field contains any whitespace.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Client Script to Validate Whitespaces
2+
var reg = /\s/;
3+
var value = g_form.getValue('field_name');
4+
var k = reg.test(value);
5+
6+
if (k == true) {
7+
alert('Field Name cannot have spaces!'); // Alert if field contains whitespace
8+
g_form.setValue('field_name', ''); // Empty field for any whitespaces
9+
}

0 commit comments

Comments
 (0)