Hi I hope someone can help me,
I'm a complete Javascript novice and I have pieced together a validation script for a form using examples.
I have attached both the webpage and .js file for anyone to take a look at... My problem is that the script only seems to work, (produce an error message when an invalid selection is made), in Internet Explorer and Opera. When using any varient of Mozilla, such as Netscape or FireFox the script fails to operate.
The beginning of the Form in the HTML page looks like this:
<form name="rqstForm" action="./makerequest.pl" onSubmit="validate();" method=GET>
and the Javascript is:
function validate() {
checkProgramme();
checkCapacity();
checkWeeks();
}
function checkProgramme() {
if (rqstForm.programme.value != "select") {
}
else {
alert('You must select a programme.');
return false;
}
}
function checkCapacity() {
if ((rqstForm.capacity.value >0) && (rqstForm.capacity.value <501)) {
}
else {
alert('Capacity must be between 1 and 500.');
return false;
}
}
function checkWeeks() {
if (rqstForm.endweek.value >= rqstForm.startweek.value) {
}
else {
alert('The end week must be later than the start week.');
return false;
}
}
I appologise for the untidyness of the HTML, however it was put together in a bit of a hurry and is dynamically generated by a Perl file when accessed online. The beginning of the Form is shown by a comment in the HTML file to make it easier to find.
If someone could help me fix this problem it would be very much appreciated!
Thank you.
I'm a complete Javascript novice and I have pieced together a validation script for a form using examples.
I have attached both the webpage and .js file for anyone to take a look at... My problem is that the script only seems to work, (produce an error message when an invalid selection is made), in Internet Explorer and Opera. When using any varient of Mozilla, such as Netscape or FireFox the script fails to operate.
The beginning of the Form in the HTML page looks like this:
<form name="rqstForm" action="./makerequest.pl" onSubmit="validate();" method=GET>
and the Javascript is:
function validate() {
checkProgramme();
checkCapacity();
checkWeeks();
}
function checkProgramme() {
if (rqstForm.programme.value != "select") {
}
else {
alert('You must select a programme.');
return false;
}
}
function checkCapacity() {
if ((rqstForm.capacity.value >0) && (rqstForm.capacity.value <501)) {
}
else {
alert('Capacity must be between 1 and 500.');
return false;
}
}
function checkWeeks() {
if (rqstForm.endweek.value >= rqstForm.startweek.value) {
}
else {
alert('The end week must be later than the start week.');
return false;
}
}
I appologise for the untidyness of the HTML, however it was put together in a bit of a hurry and is dynamically generated by a Perl file when accessed online. The beginning of the Form is shown by a comment in the HTML file to make it easier to find.
If someone could help me fix this problem it would be very much appreciated!
Thank you.
Comment