Question
This is my code. But I want it to display Enter a valid phone number(Like: 044-42046569 and enter a valid phone number in the phone
This is my code. But I want it to display "Enter a valid phone number(Like: 044-42046569 and enter a valid phone number in the phone textbox if I enter a text which is more or less than 12.
function doClear() { document.PizzaForm.customer.value = ""; document.PizzaForm.address.value = ""; document.PizzaForm.city.value = ""; document.PizzaForm.state.value = ""; document.PizzaForm.zip.value = ""; document.PizzaForm.phone.value = ""; document.PizzaForm.sizes[0].checked = false; document.PizzaForm.sizes[1].checked = false; document.PizzaForm.sizes[2].checked = false; document.PizzaForm.toppings[0].checked = false; document.PizzaForm.toppings[1].checked = false; document.PizzaForm.toppings[2].checked = false; document.PizzaForm.toppings[3].checked = false; return; }
function doSubmit() { if (validateText() == false) { alert("Required data missing in Step 1"); return; } if (validateRadio() == false) { alert("Required data missing in Step 2"); return; } if (validateCheckbox() == false) { alert("Required data missing in Step 3"); return; } alert("Your pizza order has been submitted."); return; }
function validateText() { var customer = document.PizzaForm.customer.value; if (customer.length == 0) return false;
var address = document.PizzaForm.address.value; if (address.length == 0) return false;
var city = document.PizzaForm.city.value; if (city.length == 0) return false;
}
function Validation() { var a = document.form.PizzaForm.phone.value; if(a=="") { alert("Please enter the contact number:"); document.form.phone.focus(); return false; } if (isNaN(a)) { alert("Please enter a valid phone number.") document.form.phone.focus((a.length < 15) || (a.length > 15)); return false; } }
function validateRadio() { if (document.PizzaForm.sizes[0].checked) return true; if (document.PizzaForm.sizes[1].checked) return true; if (document.PizzaForm.sizes[2].checked) return true; return false; } function validateCheckbox() { if (document.PizzaForm.toppings[0].checked) return true; if (document.PizzaForm.toppings[1].checked) return true; if (document.PizzaForm.toppings[2].checked) return true; if (document.PizzaForm.toppings[3].checked) return true; return false; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started