Regular expression, let me die, I only write a judgment that can only enter number!

you can only enter numbers

function NumberOnly(e, pnumber){

  if (!/^\d+$/.test(pnumber)){
    $(e).val(/^\d+/.exec($(e).val()));
  }

}

has been writing this for a long time: I can only enter numbers
I use this function
with onkeyup, but now I want other judgments, but I am dead in my mind, and it is really difficult to understand the regular table!?.
if you want to save me from a god who understands the rules and regulations, you can attach a better principle! I want to go to school!

  1. cannot enter blank
  2. can only type in lowercase English and -
  3. can only enter lowercase English and numbers
Mar.23,2021

  1. / ^\ slap swab G
  2. / ^ [a murz\ -] * $/ g
  3. / ^ [a-z0-9] * $/ g

OK, with Baidu and Google, nothing is a problem


http://www.lixuejiang.me/2016.

Menu