如何防止用户在文本字段(字符类型)中输入特殊字符(如键盘上不可见的符号)? [英] How to prevent user from entering special characters (like symbols not visible in keyboard) in a text field (Character type)?

查看:187
本文介绍了如何防止用户在文本字段(字符类型)中输入特殊字符(如键盘上不可见的符号)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止用户在AS400的文本字段(字符类型)中输入特殊字符(如键盘上看不见的符号)? 显然,在大多数情况下,iseries/as400接受它并将其保存到文件中并没有问题,但是有时当数据在下游报告系统中处理时,它会因系统中的其他错误而被拒绝.有没有办法防止进入点本身?

How to prevent user from entering special characters (like symbols not visible in keyboard) in a text field (Character type) in AS400 ?? Visibly most of the time there is no issue for iseries/as400 in accepting it and saving it into the file but sometimes when the data is handled in downstream reporting system it get rejected with different error in their system. Is there a way to prevent from the entry point itself ?

例如:在客户"的地址"字段中,最终用户从网页或文档中复制粘贴(ctrl + c ctrl + v)详细信息,导致输入垃圾字符或空值,这些字符或空值被存储而没有问题,但以后又导致其他问题报告应用程序.

eg: In Address field of a Customer, end user copy paste (ctrl + c ctrl + v ) details from a webpage or a document causing entry of junk characters or null values which get stored without issue but later cause problem in other reporting applications.

推荐答案

使用

Validate the screen field using the %CHECK function and display an error when invalid content is present.

D allow           C                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ+
D                                      abcdefghijklmnopqrstuvwxyz+
D                                      0123456789'

/free
    if %check(allow:scrfld01) > 0;
        error = 1;
    endif; 
/end-free

或者,您可以在保存记录之前遍历屏幕字段,删除允许的字符集中不存在的所有字符.

Alternately you could iterate through the screen field removing any characters which are not present in the allowed character set prior to saving the record.

这篇关于如何防止用户在文本字段(字符类型)中输入特殊字符(如键盘上不可见的符号)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆