The one problem I noticed rather quickly with X-Cart when it came to the required fields for the customer information input form (checking out / account registration) is that when it checks certain fields, like the phone number, it only checks the length. Now this is a big problem especially for us when we deal with Canadian orders because we have to verify certain things over the phone.
Normally this isn't an issue if the customer uses PayPal Pro Express Checkout as the payment method since they require a phone number but if they use our other payment method they get around the phone number by putting in some arbitrary character. To solve this I made a modification I wish to share with anyone wishing to do this.
This modification adds an extra check in the script
check_required_fields_js.js and is easy to make. Open
skin1/required_fields_js.js and on line 40 (assuming you have not modified this already), add the following:
Code:
if (document.getElementById('phone')) {
if (document.getElementById('phone').value.search(/\d{3}\-\d{3}\-\d{4}/) == -1) {
alert('Phone number must be in XXX-XXX-XXXX format and contain numbers!');
document.getElementById('phone').focus();
return false;
}
}
If you have modified the file this conditional block
must go after:
Code:
...
if (!obj.disabled && obj.type != 'hidden') {
checkRequiredShow(obj);
obj.focus();
checkRequiredShow(obj);
obj.focus();
}
return false;
}
This will work with any input field that has the ID of phone and will force the customer to provide a phone number (unless they've disabled javascript, which requires server-side intervention which I will include later on in this post).