Thanks for that info, works great for phone and other validation you already built for, but what about custom fields?
I have an address password custom field, that should only take numbers.
I have changed the phone filter validation and added some code to the if(type=='address') element like this:
else if(type=='address'){
if(typeof varform.elements['data[address][address_telephone]'] != 'undefined'){
var phoneField = varform.elements['data[address][address_telephone]'];
if(phoneField){
phoneField.value = phoneField.value.replace(/ /g,"");
if(phoneField.value.length > 0){
var filter = /^[0-9]+$/i;
if( !filter.test(phoneField.value)){
alert(hikashop['valid_phone']);
return false;
}
}
}
}
//added code for address password validation
else if(typeof varform.elements['data[address][address_password]'] != 'undefined'){
var codeField = varform.elements['data[address][address_password]'];
var filter = /^[0-9]+$/i;
if( !filter.test(codeField.value)){
alert(hikashop['valid_code']);
return false;
}
}
}
but this code doesn't work for me.
could you please help on that?
Thanks.