Skip to content

Commit df1255d

Browse files
Create Validate Short Description.js
1 parent a47a5ec commit df1255d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function onSubmit() {
2+
var shortDescription = g_form.getValue('short_description');
3+
4+
// Check for length
5+
if (shortDescription.length > 100) {
6+
alert('Short Description must not be more than 100 characters long.');
7+
return false; // Prevent form submission
8+
}
9+
10+
// Check for special characters
11+
var specialCharsRegex = /[^a-zA-Z0-9\s]/g;
12+
var specialChars = shortDescription.match(specialCharsRegex);
13+
14+
if (specialChars) {
15+
alert('Short Description contains invalid characters: ' + specialChars.join(', '));
16+
return false; // Prevent form submission
17+
}
18+
19+
return true; // Allow submission if both checks pass
20+
}

0 commit comments

Comments
 (0)