Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Test Int value in Javascript (Regular Expression)

$
0
0

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.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>