Thursday, November 12, 2009

Regular Expression To Check Input With no space using JavaScript

<html>
    <head>
        <script>
            function validateContent(evt)
            {
             var pattern =     /^\w[a-zA-Z@#0-9.]*$/;
                 if(evt.value.search(pattern) == -1)
                 {
                    alert('Space not Allowed');
                    return false;
                 }
            }
        </script>
    </head>
    <body>
        <input type='text' onkeyup='return validateContent(this);' />
    </body>
</html>



No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.