Vani
Vani

Reputation: 1353

How to remove special characters and space from textbox on keypress/edit

The textbox shows phone number with format (###)-###-####. while editing, the space & characters needs to be removed to restrict the count to 10 digits. The onkeypress function is not returning the correct value back.

$(document).ready(function () {
            $('#<%= TextBox_Phone1.ClientID%>').change(function () {
                debugger;               
                var txtphone = $('#<%= TextBox_Phone1.ClientID%>').val();
                $('#<%= TextBox_Phone1.ClientID%>').val = new RegExp(/[&\/\\#,+()$~%.'":*?<>{}]/g, '');

        });
      
        });

Upvotes: 0

Views: 171

Answers (0)

Related Questions