I'm using this coding to have someone enter text; if they have not entered anything when the click the button they get an alert box asking for some input.
What I want is to send them to a New web page once they have actually entered something.
I have tried <a href....but it appears on the page; I don't want that. I just want an automatic change to the new page after the button has been pressed and a valid input has been made.
---------------------------
What I want is to send them to a New web page once they have actually entered something.
I have tried <a href....but it appears on the page; I don't want that. I just want an automatic change to the new page after the button has been pressed and a valid input has been made.
---------------------------
Code:
<script type = "text/javascript">
function validate(){
// get inputs
name = document.getElementById("txtName").value;
//create an empty error message
errors = "";
//check name - It simply needs to exist
if (name == ""){
errors += "Please supply an answer…….. \n";
}
//end if
//check for errors
if (errors == ""){
//process the form
} else {
alert(errors);
} // end if
} // end function
</script> </head> <body> <h1>Frame...</h1> <h3><center>Mary had a _________ whose fleece was white as _______</h3> <form action = "http://example.com/"> <fieldset> <label>Name</label> <input type = "text"
size=75S%
value = ""
id = "txtName" /> <button type = "button"
onclick = "validate()">Check Your Answer </button>;
</fieldset>
Comment