I'm not sure what I could be doing wrong, but why when I 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 I apply the RegEx on the JavaScript it doesn't work properly? I mean, its only showing red for numeric or characters. Instead green for numeric and red for characters. HTML:
<input type="text" name="age" id="msisdn" onKeyUp="checkKey()"> JavaScript:
function checkKey() { var msisdn = document.getElementById("msisdn"); if (msisdn.value == /^[\d{9}]*$/) { msisdn.style.color = "#00b300"; } else { msisdn.style.color = "#ff0000"; } }