Im a student studying Web Development/Design and I am having an issue with some JavaScript for one of my assignments.
I am having trouble validating a form on submit. Everything validate nicely except for the selection list. Below is the script I have for the selection list so far:
if((!document.clientfeedback.staff.selectedIndex==0))
{
alert(“You must choose the number of staff”);
document.clientfeedback.staff.focus();
return false;
}
if((document.clientfeedback.staff.selectedIndex==0))
{
alert("You must choose the number of staff");
document.clientfeedback.staff.focus();
return false;
}
[list][]inline event attributes and inline scripting are used, whereas traditional scripting events (or even advanced ones) are now the favored technique
[]Script is in the head, whereas we now put our scripts at the bottom
[*]A button is used to trigger the script to submit the form, whereas a standard submit button should be used instead[/list]
In fact, their example code can be completely replaced with HTML only code, no scripting. Their scripting example provide no benefit over standard techniques.
Actually, their scripted form example completely fails to work at all when scripting is not available. This surprizingly means that an HTML-only solution is superior in practice to their script coded example. Not a good look.
Most of their other code examples face similar “out of date” problems too.
w3schools used to be a good resource, but it has long since been surpassed by the passage of time and circumstance.