dogger
11-25-2002, 12:39 PM
I am fairly new to using Javascript and need some help figuring out what I am doing wrong with the following script.
------------------------------------------
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkEntrys() {
if (!order1.Breed.value) {
alert("Please enter the breed.");
order1.Breed.focus();
return false;
}
if (!order1.Reg.value) {
alert("Please enter the registration type.");
order1.Reg.focus();
return false;
}
if (order1.Reg.value != "PUR") {
if (!order1.Regnumb.value)
alert("Please enter the registration number.");
order1.Regnumb.focus();
return false;
}
return true;
}
// End -->
</script>
------------------------------------------
I run this code when a submit button is clicked. The "Breed" and "Reg" checks work fine but I run into a problem with the last check when the "Reg" value is something other that "PUR".
What I want to happen is when the "Reg" value is "PUR" I want the page to be submitted. When the "Reg" value is something other that "PUR" I want to make sure the "Regnumb" value is not null.
The submit button works when the "Reg" value is "PUR", but when it is another value the 'return true' is never gotten to and the page remains displayed and does not bring up the next page like it should.
I would appreciate some help with how I have coded this script. It is probably something simple, so please be kind and don't burn me too bad.
Thanks
Dogger
------------------------------------------
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkEntrys() {
if (!order1.Breed.value) {
alert("Please enter the breed.");
order1.Breed.focus();
return false;
}
if (!order1.Reg.value) {
alert("Please enter the registration type.");
order1.Reg.focus();
return false;
}
if (order1.Reg.value != "PUR") {
if (!order1.Regnumb.value)
alert("Please enter the registration number.");
order1.Regnumb.focus();
return false;
}
return true;
}
// End -->
</script>
------------------------------------------
I run this code when a submit button is clicked. The "Breed" and "Reg" checks work fine but I run into a problem with the last check when the "Reg" value is something other that "PUR".
What I want to happen is when the "Reg" value is "PUR" I want the page to be submitted. When the "Reg" value is something other that "PUR" I want to make sure the "Regnumb" value is not null.
The submit button works when the "Reg" value is "PUR", but when it is another value the 'return true' is never gotten to and the page remains displayed and does not bring up the next page like it should.
I would appreciate some help with how I have coded this script. It is probably something simple, so please be kind and don't burn me too bad.
Thanks
Dogger