Wednesday, March 5, 2014

Text input validation

Text input validation with jquery
 <script type="text/javascript">
  $(function () {
            $('input[type=text]').on('keyup', function (e) {
                if (/[^.a-z_ 0-9- A-Z]/.test(this.value)) {
                    this.value = this.value.replace(/[^.a-z_ 0-9- A-Z]/g, '');
                }
            });
        });   
</script>

this will allow only A to Z ,a to z , 0-9 and some character ,-_. also

No comments:

Post a Comment