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

How to use SUM() in MySQL for calculated values -

ios - IBOutlet for image button not correctly referencing button after recreating outlet -

java - AEM: 403 Forbidden occurs when call a Post servlet -