progfrog
Mar 26th 2008, 2:46 am
hi-
does any of you know why this function doesn't work?
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>MyForm</title>
<style type="text/css">
.loud{
border: 3px double red;
background-color: yellow;
color: blue;
width: 100px;
padding: 30px;
margin: 20px;
}
</style>
<script type="text/javascript">
var text;
function Validform(Form1){
var MyName = document.getElementById("name1");
if( Form1.MyName.value=="")
text = "Name is required";
}
var getDiv = document.getElementById("eroorBox");
getDiv.innerHTML=text;
</script>
</head>
<body>
<form name="MyForm" onSubmit="return ValidForm('MyForm')" action="http://www.htmlcodetutorial.com/cgi-bin/mycgi.p"/>
<table style="width: 90%;" align="left">
<tr>
<td>
Your errros:
</td>
<td>
<div class="loud" id="errorBooks">
</div>
</td>
</tr>
<tr>
<td style="width: 200px">
Name
</td>
<td>
<input id="name1" size="25" maxlength="50" value="" />
</td>
</tr>
<tr>
<td>
Age
</td>
<td>
<input name="Age" size="25" maxlength="50" value="" />
</td>
</tr>
<tr>
<td>
Email adress:
</td>
<td>
<input name="em" size="25" maxlength="50" dir="ltr" value="" />
</td>
</tr>
<tr>
<td><input type="radio" value="Male" id= "radio1" Name="radio group" checked/> Male
<input id="radio2" type="radio" value= "Female" Name="radio group" /> Female</td>
</tr>
<tr>
<td align="left">Comments:
</td>
<td>
<textarea cols="24" id="Message" rows="6" style="width:25%";></textarea>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="submit" name="Submit" />
</td>
</tr>
</table>
</form>
does any of you know why this function doesn't work?
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>MyForm</title>
<style type="text/css">
.loud{
border: 3px double red;
background-color: yellow;
color: blue;
width: 100px;
padding: 30px;
margin: 20px;
}
</style>
<script type="text/javascript">
var text;
function Validform(Form1){
var MyName = document.getElementById("name1");
if( Form1.MyName.value=="")
text = "Name is required";
}
var getDiv = document.getElementById("eroorBox");
getDiv.innerHTML=text;
</script>
</head>
<body>
<form name="MyForm" onSubmit="return ValidForm('MyForm')" action="http://www.htmlcodetutorial.com/cgi-bin/mycgi.p"/>
<table style="width: 90%;" align="left">
<tr>
<td>
Your errros:
</td>
<td>
<div class="loud" id="errorBooks">
</div>
</td>
</tr>
<tr>
<td style="width: 200px">
Name
</td>
<td>
<input id="name1" size="25" maxlength="50" value="" />
</td>
</tr>
<tr>
<td>
Age
</td>
<td>
<input name="Age" size="25" maxlength="50" value="" />
</td>
</tr>
<tr>
<td>
Email adress:
</td>
<td>
<input name="em" size="25" maxlength="50" dir="ltr" value="" />
</td>
</tr>
<tr>
<td><input type="radio" value="Male" id= "radio1" Name="radio group" checked/> Male
<input id="radio2" type="radio" value= "Female" Name="radio group" /> Female</td>
</tr>
<tr>
<td align="left">Comments:
</td>
<td>
<textarea cols="24" id="Message" rows="6" style="width:25%";></textarea>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="submit" name="Submit" />
</td>
</tr>
</table>
</form>