My requirement to return true
or false
based on checking whether a string is single word with only Alphabets in it.
I tried following:
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction(){
document.getElementById("demo").innerHTML = /[a-zA-Z]+/.test("Hello123");
}
</script>
But this is returning me true
instead of expected false
Am I using regexObject.test( String )
in wrong way ?