javascript - Regular expression acting weird? -


if have:

var invalidcharacters = /[-+e.]/i;  

and

if(invalidcharacters.test(document.getelementbyid("postcode").value)) {   var error_cardno ="please use numbers in post code.";   document.getelementbyid("formtital").innerhtml=error_cardno;    console.log("test invalidcharacters true in cardno");   return; } 

i enter input "+", , gets pass, despite

var invalidcharacters = /[-+e.]/i; 

the test true if input has "-", "e" , "." , why not "+"?

why not true on test if input has +, , how fix true? scenario same several validations throughout code. let me know if need full function!

(have mercy i'm new)

sorry guys, understand can not reproduce problem code shown. however, problem still there (for whatever unknown reason).

however, has same problem me, try setting input giving woe text not numbers. there seems letting - + pass when input number type.

doing fixed code. help!


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -