catalog variable can set only allow half-width input?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 02:26 AM
Hi ,
For a catalog variable, when user input full-width, Is it possible to examine full-width, and alert user can only input half-width? Thank you!
Labels:
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2022 03:02 AM
Hi 1307,
Is the question about checking a field to validate to only half-width character. If so, following script will validate value.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (!validateHalfChar(newValue)) {
g_form.showFieldMsg('field', 'Full-width character not allowed.', 'error');
}
function validateHalfChar(str) {
var pattern = /^[\s\"\'!#$%&()*+,.\/0-9:;<=>?@A-Z\[\x5c\]^_`a-z{|}~]*$/;
return pattern.test(str);
}
}
Execution result:
case 1: Only half-width character
case 2: Includes full-width character