Hello!

I use masked-inputs during registration and authorization on the site. Login has the form - 7 (888) 888-88888. How to make so that in a DB only numbers without gaps, dashes and brackets are entered?

Thanks for any help!

    2 answers 2

    var login = document.getElementById("login").value; // все кроме цифр удалится из логина login = login.replace(/[^\d]+/g, ""); 

      If you need to put in the database, it is better to do it on the server side

       preg_replace("/[^0-9]/", '', $str);