<form name="form1">
<input type="textbox" name="txtInput" />
<script type="text/javascript">
function validate() {
if (! document.form1.txtInput.value.match(/\bSun(il)? (Mishra)?\b/)){
alert("Please enter valid value!");
} else {
alert("Success!");
}
}
</script>
<input type="button" name="btnSubmit" onclick="validate()" value="Go" />
It gives success on Sunil Mishra, Sun Mishra but not for Sunil OR Sun. I tried entering the input with space, but that also doesn't work.
Is there some issue in the code?