On VM1, Hutson showed us how to stop users from certain UK postcodes not register - http://forum.virtuemart.net/index.php?topic=92466.0
Is this possible on VM3? Or is there a better way? Thanks in advance.
Did you do a proper forum search? See http://forum.virtuemart.net/index.php?topic=128533
I have already got this plugin which is fantastic for delivery rates but it doesn't stop users registering with the a postcode in the wrong area.
Jim what are you trying to do
registering with postcode in wrong area means nothing to me.
I am trying to stop users who live in certain postcodes to register. Basically I only want users who have the following postcodes to register - TS1, TS2, TS4, TS5.
Could I use the same regex code as I did in VM1? The question is on which file though?
Change the zip/postcode user field to a dropdown with choice of only those values and make it a mandatory field.
But then they would need to enter the second half of their postcode. Just having "TS1" wouldn't tell you exactly where to deliver to
Jim
Second time for this and yes you should reuse the regex element you already have working.
IN Vm 3 just create an override to:-
templates/YOURTEMPLATE/html/com_virtuemart/user/edit_address.php
Add the java below just above the <form> element
And adjust the regex and message to meet your needs ( the red stuff below)
<?php
$this->vmValidator();
?>
<script language="javascript">
//quorvia add validator element for uk zip test
window.addEvent('domready',
function() {
document.formvalidator.setHandler('UKzip',
function (value) {
var regex = /^([a-zA-Z]{1,2}[0-9R][0-9a-zA-Z]? [0-9][abd-hjlnp-uw-zABD-HJLNP-UW-Z]{2})$/;
if (regex.test(value)) {
return true;
} else {
var msg = 'Please enter a valid UK post code - e.g. KA27 8AA';
alert(msg + ' ');
return false;
}
}
);
});
</script>
<script language="javascript">
//quorvia end
//quorvia new checks for UK postcode format on virtuemart_country_id and shipto_virtuemart_country_id
jQuery(document).ready(function(){
var country = '';
var shipto_country = '';
var country = jQuery('#virtuemart_country_id').val();
var shipto_country = jQuery('#shipto_virtuemart_country_id').val();
if (country != '') {
if (country == '222') {
var elem = jQuery('#zip_field');
elem.attr('class', 'validate-UKzip');
} else {
var elem = jQuery('#zip_field');
elem.attr('class', 'required');
}
}
if (shipto_country != '') {
if (shipto_country == '222') {
var elem = jQuery('#shipto_zip_field');
elem.attr('class', 'validate-UKzip');
} else {
var elem = jQuery('#shipto_zip_field');
elem.attr('class', 'required');
}
}
jQuery('#virtuemart_country_id').change(function(){
var qcountry = jQuery('#virtuemart_country_id').val();
if (qcountry != '') {
if (qcountry == '222') {
var elem = jQuery('#zip_field');
elem.attr('class', 'validate-UKzip');
} else {
var elem = jQuery('#zip_field');
elem.attr('class', 'required');
}
}
jQuery('#zip_field').focus();
}
);
jQuery('#shipto_virtuemart_country_id').change(function(){
var qcountryship = jQuery('#shipto_virtuemart_country_id').val();
if (qcountryship != '') {
if (qcountryship == '222') {
var elem = jQuery('#shipto_zip_field');
elem.attr('class', 'validate-UKzip');
} else {
var elem = jQuery('#shipto_zip_field');
elem.attr('class', 'required');
}
}
jQuery('#shipto_zip_field').focus();
}
);
});//quorva UK zip check end
</script>
Wow, thanks a lot.
Its only good if it works for you - but it should do! :D
I will try it out when I get started on this website, waiting on the client to give the "go ahead"!