关于“支票用途,汇款备注(附言)”界面录入要素的检验问题

业务需求书上要求:用途,备注(附言)栏输入的字符,系统要控制非法字符。包括但不限于符合GB2132编码规定;对X字符集的“℅、:、”等字符进行录入控制,
若录入非法字符时显示提示。我的理解是:支票用途,汇款备注(附言)输入栏,可以输入 ! % 《》 { } ( ); ^_^ 当然中文和英文是可以的啦。
我的实现代码如下 ,但不能完全实现这个功能,请各位牛人来协助解决。

private bool submitValidate()
{
//校验用途是否符合G字符集
if (!ClientValidationHelper.GB2312CharSetCheck(this.bos_ct_purpose.Text))
{
MessageInfoHelper.Instance.ShowMessage("用途输入格式非法!不允许X字符集的“%、:、”等字符");
return false;
}
if (!this.Validate(this.data))
{
return false;
}
if (this.bos_ct_purpose.GetValue().ToString() == "")
{
MessageInfoHelper.Instance.ShowErrorMessage("请输入业务要素!");
return false;
}
return true;
}

/// 检查数据是否符合GB2312标准
/// <param name="gb2312String"></param>

public static bool GB2312CharSetCheck(string gb2312String)
{
if (gb2312String == null)
return false;
gb2312String = gb2312String.Trim();
byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(gb2312String);
return GB2312CharSetCheck(bytes);
}

/// 检查数据是否符合GB2312标准
/// <param name="gb2312bytes"></param>
public static bool GB2312CharSetCheck(byte[] gb2312bytes)
{
if (null == gb2312bytes)
return false;
for (int i = 0; i < gb2312bytes.Length - 1; i++)
{
int current = Convert.ToInt32(gb2312bytes[i]);
int next = Convert.ToInt32(gb2312bytes[i + 1]);

if ((current >= 0x81) && (current <= 0xFE) && (next >= 0x40)
&& (current != 0x7F) && (current != 0x7B) && (current != 0x7D) && (next <= 0xFE))
{
continue;
}
else
return false;
}

return true;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值