有个需求是:客户会不断的在第三方软件录入人事信息,其中录入身份证号时担心输错,需要编写个后台运行的判断软件。当出现身份证号多位、少位、输错等情况自动弹出对话框提示。注:身份证生成的逻辑关系可以通过有关部门得到。以上需求可以通过什么方法实现?用什么软件编写?是否记录键盘?等等。。坐等结果!!

解决方案 »

  1.   

    你是要在数据库级别进行判断吗?办法倒是有两种:一是快照差分,而是日志分析(很多数据库都提供日志分析接口),不过两个都很麻烦。你为什么不在录入的时候判断啊(就算是第三方软件你不能改,叫原来的开发商改他们也得改啊,这属于软件的bug)。
      

  2.   


    import java.io.*;import java.lang.*;public class VerifyIpCard { public static void main(String[] args) throws IOException {  System.out.println("please input the id card number:");  BufferedReader s = new BufferedReader(new InputStreamReader(System.in));  String ww = s.readLine();  if (ww.length() == 15)  {   System.out.println("It's the new ID card!");   getInfof(ww);   Convert(ww);  }  else if (ww.length() == 18)  {   System.out.println("It's the new ID card!");   getInfoe(ww);  }  else   System.out.println("The length of the ID Card is not RIGHT!"); } static void getInfof(String s) {  String M = new String(s);  int y = Integer.parseInt(M.substring(6, 8));  int m = Integer.parseInt(M.substring(8, 10));  int d = Integer.parseInt(M.substring(10, 12));  if (m < 1 || m > 12 || d < 1 || d > 31
        || ((m == 4 || m == 6 || m == 9 || m == 11) && d > 30) ||    (m == 2 && (((y + 1900) % 4 > 0 && d > 28) || d > 29)))  {
       System.out.println("身分証出身年月エラー!");
      }  else {   System.out.println("故郷:" + M.substring(0, 6));   System.out.println("年月日:" + y + "年" + m + "月" + d + "日");
      }  int sex = Integer.parseInt(M.substring(14, 15));  if (sex % 2 == 0)  {
       System.out.println("该居民为:女性");
      }  else  {
       System.out.println("该居民为:男性");  } } static void getInfoe(String s) {  String M = new String(s);  int y = Integer.parseInt(M.substring(6, 10));  int m = Integer.parseInt(M.substring(10, 12));  int d = Integer.parseInt(M.substring(12, 14));  int[] xx = { 2, 4, 8, 5, 10, 9, 7, 3, 6, 1, 2, 4, 8, 5, 10, 9, 7 };  char[] yy = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };  int mm = 0;  int[] gg = new int[18];  if (y < 1900 || m < 1 || m > 12 || d < 1 || d > 31
        || ((m == 4 || m == 6 || m == 9 || m == 11) && d > 30) ||    (m == 2 && ((y % 4 > 0 && d > 28) || d > 29)))  {
       System.out.println("該居民身份證出生年月日錯誤!");
      }  else {   System.out.println("该居民出生地:" + M.substring(0, 6));   System.out.println("该居民出生时间为:" + y + "年" + m + "月" + d + "日");
      }  int sex = Integer.parseInt(M.substring(16, 17));  if (sex % 2 == 0)  {
       System.out.println("该居民为:女性");
      }  else  {
       System.out.println("该居民为:男性");  }  for (int i = 1; i < 18; i++)  {
       int j = 17 - i;   gg[i - 1] = Integer.parseInt(M.substring(j, j + 1));  }  for (int i = 0; i < 17; i++)  {
       mm += xx[i] * gg[i];
      }  mm = mm % 11;  char c = M.charAt(17);  if (c == yy[mm])   System.out.println("该居民身份证是真的");  else   System.out.println("该居民身份证是假的(校验码有误)"); } static void Convert(String s) throws IOException {  StringBuffer sad = new StringBuffer(s);  sad.insert(6, "19");  int[] xx = { 2, 4, 8, 5, 10, 9, 7, 3, 6, 1, 2, 4, 8, 5, 10, 9, 7 };  char[] yy = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };  int mm = 0;  int[] gg = new int[18];  for (int i = 1; i < 18; i++)  {
       int j = 17 - i;   gg[i - 1] = Integer.parseInt(sad.substring(j, j + 1));  }  for (int i = 0; i < 17; i++)  {
       mm += xx[i] * gg[i];
      }  mm = mm % 11;  System.out.println("该居民身份证是新的身份证" + sad + yy[mm]);
     }
    }
    这个可以验证
      

  3.   

    这种东西当然是在前台判断吧?格式采用js判断
    内容用ajax判断
      

  4.   

    swing的话     public void setInputVerifier(javax.swing.InputVerifier);public abstract class javax.swing.InputVerifier extends java.lang.Object{
        public javax.swing.InputVerifier();
        public abstract boolean verify(javax.swing.JComponent);
        public boolean shouldYieldFocus(javax.swing.JComponent);
    }在 verify方法里 调用验证输入的身份证号。