Brian said:
"Sue" <Su***@comcast.net > wrote:
If you could make the changes to the code that you mentioned and
post it I would greatly appreciate it.
Hmmmm... Asking a newsgroup to fix your homework? Is that ethical? Part of
the learning process is using resources to find solutions by your self....
It's certainly more ethical than the students who try to pretend
that it isn't homework: "My client would like a form that allows
the visitor to type his name and have the message 'Hello, <name>!'
appear in a popup alert box."
I don't mind answering questions or giving tips, but I won't go
so far as to complete the assignment.
Here's a simple example of form validation. In production,
I would use a regular expression to test to see if the field
contains valid data, but that's beyond the scope of this
assignment.
<html>
<head>
<script type="text/javascript">
function Validate(f){
// f is a reference to the form to be validated.
// This function returns true if all fields are valid
// or false if any are invalid.
if(f.FirstName.value==""){ // Note: no space between quotes
alert("Please enter a value for First Name");
f.FirstName.focus();
return false;
}
if(f.LastName.value==""){
alert("Please enter a value for Last Name");
f.LastName.focus();
return false;
}
return true; // All fields are valid.
}
</script>
</head>
<body>
<form onsubmit="return Validate(this)">
First Name: <input name="FirstName"><br>
Last Name: <input name="LastName"><br>
<input type="Submit" value="Send">
</form>
</body>