[cmsms_row data_width=”boxed” data_padding_left=”3″ data_padding_right=”3″ data_color=”default” data_bg_color=”#ffffff” data_bg_position=”top center” data_bg_repeat=”no-repeat” data_bg_attachment=”scroll” data_bg_size=”cover” data_bg_parallax_ratio=”0.5″ data_color_overlay=”#000000″ data_overlay_opacity=”50″ data_padding_top=”0″ data_padding_bottom=”50″][cmsms_column data_width=”1/1″][cmsms_js]$(function() {
$(‘.msg’).hide();
$(“#rx-btn”).click(function(ev)
{
ev.preventDefault();
if($(this).hasClass(‘disabled’)) return false;
var el = $(‘#rx-form’);
// Reset Warning fields
el.find(“input”).removeClass(‘warning’);
// Get values
//Special code to get the RX numbers from the multiple fields
var rx_numbers = $(‘.RxNumbers’).map(function() {
return this.value;
}).get().join(‘,’).replace(/,+/g, ‘,’).replace(/,$/g, ”);
//var rx_numbers = $(‘.RxNumbers’).map(function() { return this.value; });
//var arr = rx_numbers;
//var len = arr.length;
//for(i = 0; i < len; i++ ) { arr[i] && arr.push(arr[i]); }
//arr.splice(0 , len);
//len = arr.length;
//rx_numbers = arr.get().join(‘,’).replace(/,+/g, ‘,’).replace(/,$/g, ”);
var params = {
lastName : el.find(‘.lastName’).val(),
email : el.find(‘.email’).val(),
phone : el.find(‘.phone’).val(),
birthDate : el.find(‘.birthDate’).val(),
// RxNumbers : el.find(‘.RxNumbers’).val(),
RxNumbers : rx_numbers,
// num_refills : len,
deliveryMethod : el.find(‘.deliveryMethod’).val()
}
// Validate Info
var error = false;
$.each(params, function(k,v) {
if(v === “”) {
error = true;
el.find(“.”+k).addClass(‘warning’);
}
if(k == “phone” && v.length < 9) {
error = true;
el.find(“.”+k).addClass(‘warning’);
}
});
//alert(params);
// Stop if there are any errors
if (error) return false;
// Send Info to refill id
$(‘#rx-btn’).html(‘Renewing…’).addClass(‘disabled’);
$.ajax({
type: “POST”,
url: “/refills/refillrequest.php”,
data: params
}).done(function( msg ) {
$(‘#rx-btn’).html(‘Renew’).removeClass(‘disabled’);
$(‘#refill-msg’).html(msg);
});
});
}); [/cmsms_js][/cmsms_column][/cmsms_row]