Last active
August 2, 2016 22:14
-
-
Save m0rsecode/53d354246b98d8b72141aeb72a901404 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
console.log("CHEESE-ITZ"); | |
$('#txtPhone').on('input', function(e) { | |
if (validatePhone('txtPhone')) { | |
$('#txtSubmit').prop('disabled', false); | |
} | |
else { | |
$('#txtSubmit').prop('disabled', true); | |
} | |
}); | |
$('#txtSubmit').on('click', function(e) { //use on if jQuery 1.7+ | |
e.preventDefault(); //prevent form from submitting | |
var number = $('#txtPhone').val().replace(/\W/g, ''); | |
//console.log($('#txtPhone').val().replace(/\W/g, '')); | |
//var data = $("#login_form :input").serializeArray(); | |
$.ajax({ | |
url: "http://nineninechat.herokuapp.com/sms/" + number, | |
}).done(function() { | |
$('#txtSuccess').show(); | |
$('#txtContent').hide(); | |
}); | |
//console.log(data); //use the console for debugging, F12 in Chrome, not alerts | |
}); | |
$('#txtPhone').mask('(000) 000-0000'); | |
}); | |
function validatePhone(txtPhone) { | |
var a = document.getElementById(txtPhone).value; | |
var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{4}?$/; | |
if (filter.test(a)) { | |
return true; | |
} | |
else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment