douweibiao8471 2015-05-27 06:51
浏览 71
已采纳

输入字段字符序列

Input Field to follow and check for the following algorithm. Maximum 11 alpha-numeric characters:

  1. 1st to 4th characters => Alphabetic characters- no numbers and special characters.

  2. 5th characters => 0 (Just a single Zero)

  3. 6th to 11th Characters => Alpha-numeric.

I think my question is quite simple, i want to enter 11 characters in an input field but first 4 characters should be as defined in point 1 and 5th character should be 0 and 6th characters to onward alphanumeric . input field should allow to enter characters as i defined , if some one want to enter 1 or other character at 5ht positions input field should not allow because 5ht position is for 0 and same expressions for other positions.

  • 写回答

3条回答 默认 最新

  • douchao9899 2015-05-27 06:54
    关注

    Looks like you have to use regex:

    $('input').val().match(/^[a-z]{4}0[a-z0-9]{6}$/i);
    
    1. ^ : Starts with
    2. [a-z] : Allows Alphabetic characters
    3. {4}: Matches 4 preceding characters
    4. 0 : Matches 0
    5. [a-z0-9]: Matches any characters from a-z and 0-9 in any sequence
    6. $: End of string
    7. i: Case insensitive match
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题