Skip to content

Instantly share code, notes, and snippets.

@turnipsoup
Created April 23, 2018 15:53
Show Gist options
  • Save turnipsoup/c8c7a306f1d46dd526e64a953c5c30e6 to your computer and use it in GitHub Desktop.
Save turnipsoup/c8c7a306f1d46dd526e64a953c5c30e6 to your computer and use it in GitHub Desktop.
phone-number-cleaner
<head>
<title>Phone Number Cleaner</title>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<div class='main-holder text-center'>
<h1>Phone Number Cleaner</h1>
<h3>Will remove those stupid punctuation marks customers leave inside of phone numbers</h3>
<textarea class="number_input" placeholder="Enter numbers here separated by a new line"></textarea>
<br>
<button onclick="phonecleaner()" class="btn btn-success">Run</button>
<br>
<pre class="output"></pre>
<div>
<script>
function phonecleaner() {
$(".output").empty()
for (i=0; i<$(".number_input").val().length;i++) {
$(".output").append($(".number_input").val()[i].replace(/[.,\/#!$%\ ^&\*;:{}=\-_`~()+]/g,""))
}
$(".output").append()
}
// str.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"")
//$(".number_input").val()
</script>
<style>
body {
background-color: #404751;
color: #E0D5B7;
}
pre {
background-color: #ADABAC;
}
.main-holder {
margin: auto;
position: relative;
width: 900px;
border: solid black 1px;
top: 50px;
background-color: #5E7489;
border-radius: 10px;
}
.number_input {
color: black;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment