hi,
i am new to java script but my code is not working...please do tell the error in my code
<script language="javascript">
function validateform() {
valid=true;
for (var i=0; i < document.userdetails.elements.length; i++) {
var element = document.userdetails.elements;
switch (element.name){
case "cname":
if (element.value.length==0) valid=false;
break;
case "address":
if (element.value.length==0) valid=false;
break;
}
}
if (valid) {
respons = confirm("Do you want to proceed?");
if (respons) return true;
else return false;
} else {
alert ("Please fill in all required fields marked with *");
return false;
}
return false;
}
</script>
<script language="javascript" src="utils.js"></script>
</head>
<body>
<form method="post" action="care1.php" onSubmit="return validateform();">
<table>
<tr>
<td>Company Name </td>
<td><input type="text" name="cname" size="53"></td>
<td><span style="color:red;">*</span></td>
</tr>
<tr><td>Address </td>
<td><TEXTAREA NAME="caddr" COLS=40 ROWS=3></TEXTAREA></td>
<td><span style="color:red;">*</span></td>
</tr>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>