jQuery Inputmask纬度和经度验证和掩盖?

时间:2018-12-28 06:24:09

标签: javascript jquery latitude-longitude masking jquery-inputmask

我正在使用InputMask Jquery库进行纬度和经度遮罩,任何人都知道如何使用该库执行此操作。

屏蔽应返回以下值的true

90.366565665 -90.365333336 +90.365333336 180.36663663 -180.36633666 +180.36633666

谢谢, 卡莱姆

2 个答案:

答案 0 :(得分:0)

尝试这样的事情:

$("#Longitude").inputmask({
    mask: "E|W99[9].999",
    definitions: {
        "E": {
            validator: "[eE]",
            cardinality: 1,
            casing: "upper"
        },
        "W": {
            validator: "[wW]",
            cardinality: 1,
            casing: "upper"
        }
    }
});

参考:https://github.com/RobinHerbots/Inputmask/issues/770

答案 1 :(得分:0)

__°__'__“ _

您输入的文本字段如上

if (type === 'lt') {
  $('input#' + id).inputmask({
    mask: '89°M9\'S9"D',
    definitions: {
      D: {
        validator: '[eE|wW]',
        cardinality: 1,
        casing: 'upper'
      },
      M: {
        validator: '[0-5]',
        cardinality: 1
      },
      S: {
        validator: '[0-5]',
        cardinality: 1
      },
      8: {
        validator: '[0-8]',
        cardinality: 1
      }
    }
  });
} else if (type === 'lg') {
  $('input#' + id).inputmask({
    mask: ['99°M9\'S9"D', '[1]79°M9\'S9"D'],
    definitions: {
      D: {
        validator: '[nN|sS]',
        cardinality: 1,
        casing: 'upper'
      },
      M: {
        validator: '[0-5]',
        cardinality: 1
      },
      S: {
        validator: '[0-5]',
        cardinality: 1
      },
      7: {
        validator: '[0-7]',
        cardinality: 1
      }
    }
  });
}