javascript - I need to let the user input any numbers and characters and only the '-' or the '\' in a field. How do I do that with regular expression? -


A user can enter a serial number with a number or character and only the following special characters: '-' ' '. This is in my code:

  if (/ [- \\ a-zA-Z0- 9] /i.test(serialNumber)) {$ ('# serialErrorMsg') .html ( & Lt; div & gt; Invalid format. & Lt; br & gt; beat serial number & lt; br & gt; column name to see valid format; ;);   

When I put it in a Regedx editor and used the following serial; P23edf-A returns my warning message as a test case in the form of an invalid format.

Maybe it's too late (in the evening and I'm tired), but do you mean If not you do not?

  if (! / [- \\ a-zA-Z0- 9] + / I.test (serialNumber) {{code>  

and a full string To test,

  ^ [- \\ a-zA-Z0-9] + $    

Comments

Popular posts from this blog

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

php - Sorting an multidimension array using usort fails -

Simple file compression in C -