Is there a way to convert text entered by the customer to be stored in all capital letters?
While I'm on the subject, is there a way to force telephone formatting, and remove/add dashs, spaces, periods?
document.billing.City.value = document.billing.City.value.toUpperCase();
document.billing.City.value = document.billing.City.value.replace(".","");
{
document.billing.First.value = document.billing.First.value.toUpperCase();
document.billing.Last.value = document.billing.Last.value.toUpperCase();
document.billing.City.value = document.billing.City.value.toUpperCase();
document.billing.Country.value = document.billing.Country.value.toUpperCase();
document.billing.Address 1.value = document.billing.Address 1.value.toUpperCase();
document.billing.Address 2.value = document.billing.Address 2.value.toUpperCase();
document.billing.Shipping Address 1.value = document.billing.Shipping Address 1.value.toUpperCase();
document.billing.Shipping Address 2.value = document.billing.Shipping Address 2.value.toUpperCase();
document.billing.Name On Card.value = document.billing.Name On Card.value.toUpperCase();
document.billing.First.value = document.billing.First.value.replace(".","");
document.billing.Last.value = document.billing.Last.value.replace(".","");
document.billing.City.value = document.billing.City.value.replace(".","");
document.billing.Country.value = document.billing.Country.value.replace(".","");
document.billing.Address 1.value = document.billing.Address 1.value.replace(".","");
document.billing.Address 2.value = document.billing.Address 2.value.replace(".","");
document.billing.Shipping Address 1.value = document.billing.Shipping Address 1.value.replace(".","");
document.billing.Shipping Address 2.value = document.billing.Shipping Address 2.value.replace(".","");
document.billing.Name On Card.value = document.billing.Name On Card.value.replace(".","");
if (document.billing.Phone.value.length == 10){
num = document.billing.Phone.value;
parts = [num.slice(0,3),num.slice(3,6),num.slice(6,10)];
fNum = parts[0]+"-"+parts[1]+"-"+parts[2];
document.billing.Phone.value = fNum;
}
document.billing.First.value = document.billing.First.value.toUpperCase();
document.billing.Last.value = document.billing.Last.value.toUpperCase();
document.billing.City.value = document.billing.City.value.toUpperCase();
document.billing.Country.value = document.billing.Country.value.toUpperCase();
document.billing.Address.value = document.billing.Address.value.toUpperCase();
document.billing.Address2.value = document.billing.Address2.value.toUpperCase();
document.billing.ShipAddress.value = document.billing.ShipAddress.value.toUpperCase();
document.billing.ShipAddress2.value = document.billing.ShipAddress2.value.toUpperCase();
document.billing.pay2.value = document.billing.pay2.value.toUpperCase();
document.billing.First.value = document.billing.First.value.replace(".","");
document.billing.Last.value = document.billing.Last.value.replace(".","");
document.billing.City.value = document.billing.City.value.replace(".","");
document.billing.Country.value = document.billing.Country.value.replace(".","");
document.billing.Address.value = document.billing.Address.value.replace(".","");
document.billing.Address2.value = document.billing.Address2.value.replace(".","");
document.billing.ShipAddress.value = document.billing.ShipAddress.value.replace(".","");
document.billing.ShipAddress2.value = document.billing.ShipAddress2.value.replace(".","");
document.billing.pay2.value = document.billing.pay2.value.replace(".","");
if (document.billing.Phone.value.length == 10){
num = document.billing.Phone.value;
parts = [num.slice(0,3),num.slice(3,6),num.slice(6,10)];
fNum = parts[0]+"-"+parts[1]+"-"+parts[2];
document.billing.Phone.value = fNum;
}
/* Cycle through all form elements */
for(n=0; n<document.billing.elements.length; n++){
/* only modify text fields */
if(document.billing.elements[n].type == 'text'){
/* Custom formatting for both phone text fields */
if (document.billing.Phone.value.length == 10){
num = document.billing.Phone.value;
parts = [num.slice(0,3),num.slice(3,6),num.slice(6,10)];
fNum = parts[0]+"-"+parts[1]+"-"+parts[2];
document.billing.Phone.value = fNum;
/* Exclude payment fields for credit card processing */
} else if(document.billing.elements[n].className == 'payment'){
//do nothing
/* Exclude email fields */
} else if(document.billing.elements[n].name=='email'||document.billing.elements[n].name=='email_again'){
//do nothing
/* Format text fields */
} else{
document.billing.elements[n].value = document.billing.elements[n].value.toUpperCase();
document.billing.elements[n].value.replace(".","");
}
}
}
<script src="http://code.jquery.com/jquery-latest.js"></script>
/* Cycle through all form elements */
for(n=0; n<document.billing.elements.length; n++){
/* only modify text fields */
if(document.billing.elements[n].type == 'text'){
/* Custom formatting for both phone text fields */
if (document.billing.Phone.value.length == 10){
num = document.billing.Phone.value;
parts = [num.slice(0,3),num.slice(3,6),num.slice(6,10)];
fNum = parts[0]+"-"+parts[1]+"-"+parts[2];
document.billing.Phone.value = fNum;
/* Exclude payment fields for credit card processing */
} else if(document.billing.elements[n].className == 'payment'){
//do nothing
/* Exclude email fields */
} else if(document.billing.elements[n].name=='email'||document.billing.elements[n].name=='email_again'){
//do nothing
/* Format text fields */
} else{
document.billing.elements[n].value = document.billing.elements[n].value.toUpperCase();
document.billing.elements[n].value.replace(".","");
}
}
}
if(button==162){
var s_option = $(".shipmethod").parent().text();
var so = s_option.split(':');
var ship_method = jQuery.trim(so[1]);
var po_regex = /^po.*box.*|^p\.o\..*box.*|p o box.*/i;
var ship_regex = /^UPS.*|^FedEx.*/;
if(ship_method.match(ship_regex)){
var post_office_message = "We are unable to offer shipping to Post Office addresses for this order. Please choose one of the US Postal Service options or change your shipping address.";
if(po_regex.test(document.billing.ShipAddress.value)){
alert(post_office_message);
document.billing.ShipAddress.value = "";
return(false);
}
if(po_regex.test(document.billing.ShipAddress2.value)){
alert(post_office_message);
document.billing.ShipAddress.value = "";
return(false);
}
}
}
Users browsing this forum: No registered users and 113 guests