1. // 用于存放当前修改的记录的number,方便判断用户修改过number没有
  2. String tempNumber = "";
  3. public void loadFields() {
  4. super.loadFields();
  5. tempNumber = this.editData.getNumber();
  6. }
  7. // 验证
  8. protected void verifyInput(ActionEvent arg0) throws Exception {
  9. super.verifyInput(arg0);
  10. // 车号不能为空
  11. if (txtNumber.getText().trim().equalsIgnoreCase("")) {
  12. MsgBox.showWarning("车号不能为空!");
  13. txtNumber.requestFocusInWindow();
  14. SysUtil.abort();
  15. }
  16. if (this.oprtState.equals(OprtState.ADDNEW)) {
  17. IRentVehicle rentVehicle = RentVehicleFactory.getRemoteInstance();
  18. RentVehicleCollection rentVehicleCollection = rentVehicle
  19. .getRentVehicleCollection(" where number='"
  20. + txtNumber.getText().trim() + "'");
  21. if (rentVehicleCollection.size() > 0) {
  22. MsgBox.showWarning("车号已经存在,请重新输入!");
  23. txtNumber.requestFocusInWindow();
  24. SysUtil.abort();
  25. }
  26. } else if (this.oprtState.equalsIgnoreCase(OprtState.EDIT)) {
  27. // number有改动才需要验证
  28. if (!txtNumber.getText().trim().equals(tempNumber)) {
  29. IRentVehicle irentVehicle = RentVehicleFactory
  30. .getRemoteInstance();
  31. RentVehicleCollection rentVehicleCollection = irentVehicle
  32. .getRentVehicleCollection(" where number='"
  33. + txtNumber.getText().trim() + "'");
  34. if (rentVehicleCollection.size() > 0) {
  35. MsgBox.showWarning("车号已经存在,请重新输入!");
  36. txtNumber.requestFocusInWindow();
  37. SysUtil.abort();
  38. }
  39. }
  40. }
  41. // 类型
  42. if (prmtvehicleType.getValue() == null) {
  43. MsgBox.showWarning("类型不能为空!");
  44. prmtvehicleType.requestFocusInWindow();
  45. SysUtil.abort();
  46. }
  47. // 主驾驶姓名
  48. if (txtmainDriver.getText().trim().equals("")) {
  49. MsgBox.showWarning("主驾驶姓名不能为空!");
  50. txtmainDriver.requestFocusInWindow();
  51. SysUtil.abort();
  52. }
  53. // ×××号
  54. if (txtidentityNo.getText().trim().equals("")) {
  55. MsgBox.showWarning("×××号不能为空!");
  56. txtidentityNo.requestFocusInWindow();
  57. SysUtil.abort();
  58. }
  59. // ×××号码必须是15或者18位
  60. if (!txtidentityNo.getText().trim().equalsIgnoreCase("")) {
  61. if (txtidentityNo.getText().trim().length() != 15
  62. && txtidentityNo.getText().trim().length() != 18) {
  63. MsgBox.showWarning("×××号应该为15位或18位!");
  64. txtidentityNo.requestFocusInWindow();
  65. SysUtil.abort();
  66. }
  67. }
  68. // 行驶证号
  69. if (txttravelNo.getText().trim().equals("")) {
  70. MsgBox.showWarning("行驶证号不能为空!");
  71. txttravelNo.requestFocusInWindow();
  72. SysUtil.abort();
  73. }
  74. // 驾照类型
  75. if (prmtLicenseType.getValue() == null) {
  76. MsgBox.showWarning("驾照类型不能为空!");
  77. prmtLicenseType.requestFocusInWindow();
  78. SysUtil.abort();
  79. }
  80. // 出厂日期
  81. if (pkproduceDate.getValue() == null) {
  82. MsgBox.showWarning("出厂日期必须填写!");
  83. pkproduceDate.requestFocusInWindow();
  84. SysUtil.abort();
  85. }
  86. // 签发日期
  87. if (pkissuingDate.getValue() == null) {
  88. MsgBox.showWarning("签发日期必须填写!");
  89. pkissuingDate.requestFocusInWindow();
  90. SysUtil.abort();
  91. }
  92. // 到期日期
  93. if (pkexpireDate.getValue() == null) {
  94. MsgBox.showWarning("到期日期必须填写!");
  95. pkexpireDate.requestFocusInWindow();
  96. SysUtil.abort();
  97. }
  98. // 出厂日期<签发日期
  99. if (pkproduceDate.getValue() != null
  100. && pkissuingDate.getValue() != null) {
  101. if (((Date) pkproduceDate.getValue()).after((Date) pkissuingDate
  102. .getValue())) {
  103. MsgBox.showWarning("出厂日期不能晚于签发日期!");
  104. pkproduceDate.requestFocusInWindow();
  105. SysUtil.abort();
  106. }
  107. }
  108. // 签发日期<到期日期
  109. if (pkissuingDate.getValue() != null && pkexpireDate.getValue() != null) {
  110. if (((Date) pkissuingDate.getValue()).after((Date) pkexpireDate
  111. .getValue())) {
  112. MsgBox.showWarning("签发日期不能晚于到期日期!");
  113. pkissuingDate.requestFocusInWindow();
  114. SysUtil.abort();
  115. }
  116. }
  117. // 验证电话号码格式\d{3}-\d{8}|\d{4}-\d{7}
  118. if (!txttelephone.getText().trim().equals("")) {
  119. String telephone = txttelephone.getText().trim();
  120. String style = "1\\d{10}|\\d{3}-\\d{8}|\\d{4}-\\d{7}";
  121. Pattern ptt = Pattern.compile(style);
  122. Matcher mch = ptt.matcher(telephone);
  123. if (!mch.matches()) {
  124. MsgBox.showWarning("电话号码格式不对,电话必须是正确的手机号码或者是“区号-座机号”的形式!");
  125. txttelephone.requestFocusInWindow();
  126. SysUtil.abort();
  127. }
  128. }
  129. }

转载于:https://blog.51cto.com/huqianhao/955206

金蝶BOS开发之--非空验证、时间、电话号码验证相关推荐

  1. 金蝶BOS开发中Edit编辑界面和List叙事薄界面需要写的代码

    本人刚开始从事金蝶EAS开发,对于这个也是刚刚解除,下面是一些学习整理, EditUI中的代码 public class MyBillEditUI extends AbstractMyBillEdit ...

  2. 金蝶BOS开发数据库工具类

    1.后台DbUtil用法: com.kingdee.eas.util.app.DbUtil (1)查询操作StringBuffer sql = new StringBuffer();sql.appen ...

  3. 金蝶BOS开发代码调用过程

    本文采用采购订单为例子: step1:用户打开'采购订单编辑界面'系统自动调用PurOrderEditUI.class step2:录入相关信息 step3:保存,PurOrderEditUI先进性合 ...

  4. 金蝶BOS开发数据集操作方法(sqloql)

    一.CompareType说明 CompareType.EQUALS = ("="); new FilterItemInfo("name","zll& ...

  5. 金蝶bos开发:设置ui界面窗体大小

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();// 获得屏幕象素 screenSize.setSize(800, ...

  6. JS邮箱验证_手机号码验证_电话号码验证-正则验证

    一.正则表达式 //对电子邮件的验证:^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$ //对 ...

  7. JS电话验证 Java电话号码验证 电话号码只能是11位

    JS //电话号码只能是11位var studentPhone = view.get("#studentDS").getData("#").get(" ...

  8. sencha touch Model validations 自定义验证 二选一输入验证、重复验证、时间验证、比较验证、条件验证(2015-1-14)...

    项目初始化时执行以下代码 1 //重写模型,方便进行自定义验证 2 Ext.define("Ext.zh.data.Model", { 3 override: "Ext. ...

  9. 金蝶BOS(Kingdee Business Operating System)

    金蝶BOS是什么,能给您带来什么价值? 金蝶BOS是什么? 金蝶BOS是金蝶ERP的集成与应用平台.金蝶BOS遵循面向服务的架构体系,是一个面向业务的可视化开发平台:是一个金蝶ERP和第三方应用集成的 ...

  10. HTML表单校验非空的两种方式

    HTML表单校验非空的两种方式 第一种方式 第二种方式 实例:校验表单中姓名为非空 第一种方式 let reg = /\S/; 第二种方式 let reg_name = /^\w+$/; 实例:校验表 ...

最新文章

  1. 使用AndroidStudio创建自定义gradle插件并被引用实战例子
  2. 第二届「机器智能前沿论坛」强势来袭,众多机器学习大咖邀你共话AI未来!
  3. apache+mod_wsgi+django的环境配置
  4. SAP Business ByDesign 和支付宝与钉钉集成的一个原型开发案例
  5. 中医养生 选对方法就成功一半
  6. dubbo的监控中心
  7. CMake with WinMinGW
  8. java处理超大csv文件_比较 csv 文件中数据差异
  9. ACM-ICPC 2018 南京赛区网络预赛 B The writing on the wall(暴力)
  10. 5种Python深度学习库和资料
  11. cocos creator快速上手《摘星星》官方教程续|星月爸爸
  12. 真香,50行Java代码爬取妹子套图!
  13. b站某知名云跑路云跑路是咋回事
  14. [机器学习与scikit-learn-38]:算法-分类-支持向量机-通过等高线可视化决策边界线和隔离带
  15. 苹果切换系统按哪个键_苹果全新笔记本 一体机正品专区
  16. 常用SQL语句大全实例总结-基础篇
  17. 计算机存储单位--“大数据”概念
  18. seata-tcc简单使用
  19. 控制输入框弹出弹窗 和不弹出窗口
  20. 就在今天!当当科技品类日满100减50

热门文章

  1. UILabel显示html文本
  2. NoteBurner iTunes DRM Audio Converter for Mac(苹果DRM音频转换器)
  3. Mac上Spotify 音乐添加到 djay Pro的详细教程
  4. 关于Mac电脑更新IP地址的解决方法!
  5. 在原生js中的,table表格,display:block之后,样式混乱
  6. node.js连接数据库(mysql)
  7. 今天安家 明天开始在网络的海洋里遨游
  8. 打开运行PS、AI等软件时卡在启动窗口的解决办
  9. Error fetching https://gems.ruby-china.org/: bad response Not Found 404 (https://gems.ruby-china.or
  10. 数据库DBeaverEE 22.0.2