Skip to content

Commit 4abe56c

Browse files
authored
Create validateSpecialChar.js
1 parent 0e05c51 commit 4abe56c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Client Script to Validate Special Charecters
2+
function onSubmit() {
3+
var shortDescription = g_form.getValue('short_description');
4+
var specialCharsRegex = /[^a-zA-Z0-9\s]/g;
5+
var specialChars = description.match(specialCharsRegex);
6+
if (specialChars) {
7+
alert('Description contains invalid characters: ' + specialChars.join(', '));
8+
return false;
9+
} else {
10+
return true;
11+
}
12+

0 commit comments

Comments
 (0)