...

View Full Version : javascript query



dharmistha
07-08-2005, 09:44 AM
Trying the code below to insert data into a table, the insert works properly but it gives javascript error on page. The error is 'Object doesnt this property or method'
<?
/*
db connection string goes here
*/
?>
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script language="JavaScript">
<!--
function Validate()
{
if (document.test.txtname.value=="")
{
alert("Name cannot be blank");
event.returnValue=false;
}

}
//-->
</script>
<form name="test" method="get" action="testSubmit.php" onSubmit= "Validate();" >
Name: <input type="text" name="txtname" id="txtname" value="<? echo "asdsdfsdfsdf"; ?>">
<input type="submit" name="submit" value="Submit">
<?
if (isset($_GET["submit"]))
{
/*Inserts data into a table*/
}
?>
</body>
</html>

Kor
07-08-2005, 11:01 AM
function Validatef()
{
if (f.elements['txtname'].value=="")
{
alert("Name cannot be blank");
return false;
}
}

...
<form name="test" method="get" action="testSubmit.php" onsubmit= "return Validate(this);" >

glenngv
07-08-2005, 11:09 AM
function Validatef()
{
if (f.elements['txtname'].value=="")
{
alert("Name cannot be blank");
return false;
}
}

...
<form name="test" method="get" action="testSubmit.php" onsubmit= "return Validate(this);" >
You forgot the parameter.


function Validatef(f)

Kor
07-08-2005, 11:14 AM
yeap, sorry, but you have mistyped as well :p

function Validate(f)

glenngv
07-08-2005, 11:29 AM
I just followed what you had, and I didn't notice that you just misplaced the f. :p



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum