Hi,
I have a very basic postcode validation script which works brilliantly, however I require a new validation adding to this. I want to single out people with specific postcodes, to be mor specific anyone with a Milton Keynes postcode should receive an alert when they submit the form before it goes to the serverside action page.
I can write a regular expression which detects the postcodes i want to look for, however i am lost as to how i create an alert before the form is submitted without cancelling the submission.
My current validation for the postcode looks like this:
[CODE]
var regExpressPostcode = /^([a-zA-Z]){2}([0-9][0-9]|[0-9]){1}([ ])([0-9][a-zA-z][a-zA-z]|[0-9][0-9][a-zA-z][a-zA-z]){1}$/;
function checkForm(aForm) {
if (!regExpressPostcode.test(aForm.shipPostalCode.value)){
window.alert(“Please enter a correctly formatted UK postcode: eg. AB12 2BA or AB12 12AB”)
//gives focus to field and selects incorrect postcode format text
aForm.shipPostalCode.focus()
aForm.shipPostalCode.select()
return false
}
return true
}
any help would be greatly appreciated!!
Thanks,
Mike