During some work i have tried to get a validation form working for my webpage. Out of all the alerts and if functions i've placed all but one is working. That is when i want it to validate the form's Postcode value to check it for all digits it doesn't work and will allow even 4 digits that are characters.
I've Tried many ways including :
for (var i=0;i<document.OrderForm.Postcode.value.length;i++){
temp=document.OrderForm.Postcode.value.substring(i,i+1)
if (digits.indexOf(temp)==-1){
alert("Invalid Phone Number !")
return false
}
}
and I've tried using the test functions such as
if(/^[0-9]+$/.test(document.OrderForm.Postcode.value)){
alert("Not a valid postcode")
return false
}
I've tried i think almost every possible combination of these and every variation i could think of. Any thoughts or suggestions would be greatly appreciated as i could source any help from older questions etc.
Cheers, Jesse