Friday 25 May 2012

Validation Using JavaScript


 Here is simple Code for Numeric only and Email Validation using JavaScript

<input type="text" onkeypress="return number(event);" />
<input type="text" onblur="checkEmailValidation(this);" />

    <script type="text/javascript">
        function number(e) {
          
            var unicode = e.charCode ? e.charCode : e.keyCode;
            if (unicode != 8 && unicode != 9) {
                if (unicode < 48 || unicode > 57) return false;
            }

         //   OR USE "^\d+$ "  as RegExp
        }

        function checkEmailValidation(obj) {
            var filter1 = /^.+@.+\..{2,3}$/;
            if (filter1.test(obj.value) != true) {
                alert("invalid Email");
            }
        }
    </script>


Why should be a fan as you are a star of tomorrow,,,

No comments:

Post a Comment