I have a javascript function which matches the text entered in an Ajax Combobox against a regular expression.
But seems like 'test' is not working as expected.
Below is my code and I am not getting where I am doing wrong.
<script language="javascript" type="text/javascript"> function cmbExample_OnBlur() { var regex = "^[0-9]{1,10}$"; var sel = document.getElementById("MainTextBox").value; alert(sel); if (regex.test(sel)) { alert("success"); } else { alert("error"); } }</script>
I tried converting sel into string then also it is not working.