Click to See Complete Forum and Search --> : form with validations


2 peachy
03-27-2003, 02:30 AM
I need to create a form that will gather the necessary information to open a new

browser window with a user specified URL, dimensions and features. my form should

include the following elements.

A text box to allow the user to enter a URL.
Text boxes to retrieve the top, left, width and height of the new window.
A multi-select list box, that includes at least four possible window features,

such as address bar, resizeable, scrollbars, etc.
A submit button

When the user submits the form,I want to validate the data to ensure that the URL

is not blank. The top and left dimensions must be between 0 and 100. The width

and height must be between 100 and 600. If all the data is correct,it will open a

new window with the specified URL, dimensions, and any selected feature(s).


I am not quite sure how to do this.

2 peachy
03-27-2003, 04:04 PM
ok... here is what I have so far.... not much....
I need to make functions to verify that the url has been entered, get the dimensions and location numbers,
and if everything is right.... when the submit button is hit, the user gets taken to that url with the top/ left window location they chose, as well as the width and height they chose and any features they chose....

I need help.... please


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">

function verify() {
var themessage = "You are required to complete the following fields: ";
if (document.form.url.value=="") {
themessage = themessage + " - Url";
}
if (document.form.top.value=="") {
themessage = themessage + " - Window location Top";
}
if (document.form.left.value=="") {
themessage = themessage + " - Window location Left";
}
if (document.form.width.value=="") {
themessage = themessage + " - Window width";
}
if (document.form.height.value=="") {
themessage = themessage + " - Window Height";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}
// End -->
</script>

</HEAD>

<body>
<form name=form method="post" action="">
<p>
<input type=text name="url" size="20">
Url<br>
<BR>
<input type=text name="top" size="20">
Window locaton (top) ( Between 0 and 100)<br>
<BR>
<input type=text name="left" size="20">
Window locaton (left) ( Between 0 and 100)<br>
<BR>
<input type=text name="width" size="20">
Window Width ( Between 100 and 600)<BR>
<br>
<input type=text name="height" size="20">
Window Height ( Between 100 and 600) </p>
<p>Choose features you want included</p>
<p>
<select name="mylist" size="4" multiple>
<option value="0">None</option>
<option value="1">Status Bar</option>
<option value="2">Scroll Bars</option>
<option value="3">Resizeable</option>
<option value="4">Menu Bar</option>
</select>
</p>
<p><BR>
<input type=button value="Submit Request" onclick="verify();">
<input type=reset value="Clear Form">
<br>
</p>
</form>


</body>
</html>