I'm not sure what iI could be doing wrong, but why when iI test the regular expression /^[\d{9}]*$/ on the website https://regex101.com/#javascript it match correctly if it's a number or not, but when iI apply the regexRegEx on the javascriptJavaScript it doesn'tdoesn't work properly? I mean, its only showing red for numeric or charscharacters. insteadInstead green for numeric and red for charscharacters. htmlHTML:
<input type="text" name="age" id="msisdn" onKeyUp="checkKey()"> javascriptJavaScript:
function checkKey() { var msisdn = document.getElementById("msisdn"); if (msisdn.value == /^[\d{9}]*$/) { msisdn.style.color = "#00b300"; } else { msisdn.style.color = "#ff0000"; } }