1function validate(){
2 var phoneNumber = document.getElementById('phone-number').value;
3 var postalCode = document.getElementById('postal-code').value;
4 var phoneRGEX = /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/;
5 var postalRGEX = /^[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-Z]{2}$/i;
6 var phoneResult = phoneRGEX.test(phoneNumber);
7 var postalResult = postalRGEX.test(postalCode);
8 alert("phone:"+phoneResult + ", postal code: "+postalResult);
9}
10
11