javascript - validate numeric with 1 special character -
I want to validate numerical and allow + (plus sign), but it is not working < / P>
Do I want
+63443 -> Ok 8452 - & gt; Ok s55sd - & gt; It is my code var nom = $ ("# addKonId1"). Val (). Split ("") .join ("") .replace (/ ^ \ s \ s * /, '') Replace (/ \ s \s * $ /, ''); Var intergroup = / ^ \ D + $ /; If (IntRegex.test (dot)) {Warning ("wrong number"); } And {warning (noam); }
Regular expression of what you are looking for:
^ \ +? \ D + $
which means "alternately after the beginning of a string with a plus sign after one or more points".
Your regex now just tests for a string that starts with one or more digit characters Change intRegex
as such:
< Code> var intRegex = / ^ \ +? \ D + $ / /
On a side note, what you can do when you take the place in your first line:
var Nom = $ ( "#AddKonId1"). Val (). Division ("") .join (""). Trim ();
Comments
Post a Comment