SHARE
TWEET

Untitled

a guest Jul 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function handleTelefone(event){
  2.     const regex = /^(?([0-9]{2}))?([0-9]{4,5})-?([0-9]{4})$/mg;
  3.     var str = event.target.value.replace(/[^0-9]/g, '').slice(0, 11);
  4.     const subst = `($1)$2-$3`;
  5.  
  6.     const result = str.replace(regex, subst);
  7.  
  8.     setTelefone(result);
  9. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top