catalog variable can set only allow half-width input?

____39
Tera Contributor

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!

1 REPLY 1

Hitoshi Ozawa
Giga Sage
Giga Sage

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

find_real_file.png

case 2: Includes full-width character

find_real_file.png