$(document).ready(function(){

$('#phone').blur(function(){
    $(this).val( $(this).val().replace(/[^0-9]+/g,'') );
});

$.validator.addMethod('usEmail',function(value,element){
    return this.optional(element) || /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([com|net|org]{3})+$/.test(value);
}, 'Invalid email.');

$('#debtInfo').validate({
    rules: {
        Email: {
            usEmail: true
        },
        Zip: {
            required: true,
            digits: true,
            maxlength: 5,
            minlength: 5
        },
        Home_Phone: {
            required: true,
            digits: true,
            maxlength: 10,
            minlength: 10
        }
    },
    messages: {
        First_Name: "Please fill out your first name",
        Last_Name: "Please fill out your last name",
        Email: "Please use a valid email",
        Home_Phone: "Please enter a 10 digit phone number with no punctuation (ex: 8885150055)",
        Zip: "Please enter a 5 digit zip code (ex. 55555)"
    },
    errorLabelContainer: "#formValidationError",
    errorContainer: "#formValidationError h3",
    wrapper: "li",
    highlight: function(element, errorClass) {
            $(element).addClass('error');
    }
 


});

//$('#submitForm').click(function(){
//    var curPhone = $('#phone').val();
//    alert(curPhone);
//    $('#phone').val( curPhone.replace(/[^0-9]/g,""));
////    $.post('https://leads.greatleadsllc.com/genericPostlead.php', {
////        Test_Lead:              '1',
////        TYPE:                   '1',
////        IP_Address:             '192.0.1.1',
////        SRC:                    'Gleads',
////        Landing_Page:           'Gleads',
////        Ref_ID:                 '001',
////        First_Name:             $('#fname').val(),
////        Last_Name:              $('#lname').val(),
////        Address:                'Unknown',
////        City:                   $('#city').val(),
////        State:                  $('#state').val(),
////        Zip:                    $('#zip').val(),
////        Email:                  $('#headerEmail').val(),
////        Home_Phone:             $('#phone').val(),
////        Cell_Phone:             $('#phone').val(),
////        Best_Time_to_Contact:   'Anytime',
////        Days_Behind:            $('#days_behind').val(),
////        Debt_Amount:            $('#debt_amount').val()
////    }, function(data){
////        alert(data);
////    }, 'xml');
//});


});