How to Detect Non “GSM 7 bit alphabet” characters in input field

前端 未结 5 1526
借酒劲吻你
借酒劲吻你 2020-12-10 04:47

I am trying to detect if a text input field has any character that doesn\'t belong to the GSM 7 bit alphabet. The table with the characters is here http://www.dreamfabric.co

5条回答
  •  抹茶落季
    2020-12-10 05:24

    I have textarea with id smscontent. I use below regex/code

    $('#smscontent').on('input, change keyup', function(){
        $(this).val($(this).val().replace(/[^A-Za-z0-9 \r\n@£$¥!\"#$%&'\(\)*\+,_.\/:;<=>?^{}\\\[~\]]*/ig, ''));
    });
    

    To test the regex shared by Lajos - https://www.regextester.com/99623

    To test the regex used in this answer - https://www.regextester.com/?fam=106436

提交回复
热议问题