Jump to content

[SOLVED] validate function not working???


darkfreaks

Recommended Posts

okay so i have a validate function in Javascript and it stops working after the first 2 if statements and i cant figure out why ???

 

 

function validForm(WorkOrderNew) {

if (document.WorkOrderNew.Location.selectedIndex === 0) { 
alert("You must enter a Location");
WorkOrderNew.Location.focus();
return false;
}
if (WorkOrderNew.WorkOrderName.value === "") {
alert("You must enter a Work Order Name");
WorkOrderNew.WorkOrderName.focus();
return false;
}

//does not work after this point
if (WorkOrderNew.Customer.value === "") {
alert("You must enter a Customer Name");
WorkOrderNew.Customer.focus();
return false;
}
if (document.WorkOrderNew.StartMonth.selectedIndex === 0) {
alert("You MUST enter the Start Month");
WorkOrderNew.StartMonth.focus();
return false;
}
if (document.WorkOrderNew.StartDay.selectedIndex === 0) {
alert("You MUST enter the Start Day");
WorkOrderNew.StartDay.focus();
return false;
}
if (document.WorkOrderNew.StartYear.selectedIndex === 0) {
alert("You MUST enter the Start Year");
WorkOrderNew.StartYear.focus();
return false;
}
if (document.WorkOrderNew.EndMonth.selectedIndex === 0) {
alert("You MUST enter the End Month");
WorkOrderNew.EndMonth.focus();
return false;
}
if (document.WorkOrderNew.EndDay.selectedIndex === 0) {
alert("You MUST enter the End Day");
WorkOrderNew.EndDay.focus();
return false;
}
if (document.WorkOrderNew.EndYear.selectedIndex === 0) {
alert("You MUST enter the End Year");
WorkOrderNew.EndYear.focus();
return false;
}
if (WorkOrderNew.PackageType.selectedIndex === 0) {
alert("You must Select a Package Type");
WorkOrderNew.PackageType.focus();
return false;
}
if (WorkOrderNew.Description.value === "") {
alert("You must enter a Message Body");
WorkOrderNew.Description.focus();
WorkOrderNew.Description.select();
return false;
}
if (WorkOrderNew.Phone.value === "") {
alert("You must enter a Phone");
WorkOrderNew.Phone.focus();
WorkOrderNew.Phone.select();
return false;
}
if (WorkOrderNew.City.value === "") {
alert("You must enter a City");
WorkOrderNew.City.focus();
WorkOrderNew.City.select();
return false;
}
if (WorkOrderNew.State.selectedIndex === 0) {
alert("You must enter a State");
WorkOrderNew.State.focus();
return false;
}
if (WorkOrderNew.Zip.value === "") {
alert("You must enter a Zip");
WorkOrderNew.Zip.focus();
WorkOrderNew.Zip.select();
return false;
}
if (WorkOrderNew.URL.value === "") {
alert("You must enter a URL link");
WorkOrderNew.URL.focus();
WorkOrderNew.URL.select();
return false;
}
return true;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.