Page 1 of 1

PHP onsubmit in the form not going to the fuction.

Posted: Fri Oct 30, 2009 2:58 am
by azadms
I have a form through ‘onsubmit’ calling a function validation(). But not going to the function at all. Why?

<form action="member.php" method="post" name="frmlogin" id="frmlogin" onsubmit="return validation();" enctype="multipart/form-data">
.
.
.
</form>

The function code :-
<script language="javascript">

function validation()
{

if(document.frmlogin.title.value=='')
{
alert("Please enter Title")
document.frmlogin.title.focus();
return false;
}
}
</script>

Re: PHP onsubmit in the form not going to the fuction.

Posted: Fri Oct 30, 2009 5:15 am
by Mark Baker
This is a javascript question, nothing at all to do with PHP

Have you tried debugging using FireBug or similar to confirm that it isn't executing the validation() function?

Re: PHP onsubmit in the form not going to the fuction.

Posted: Fri Oct 30, 2009 8:28 am
by godwinsam
Hello,

I have worked out the following way,

<form action="member.php" method="post" name="frmlogin" id="frmlogin" onsubmit="return validation();" enctype="multipart/form-data">
<input type="submit" name="name" value=""/>
<input type="text" name="title" value="value" size="40" maxlength="40"/>
</form>

The function code :-
<script language="javascript">

function validation()
{

if(document.frmlogin.title.value=='')
{
alert("Please enter Title")
document.frmlogin.title.focus();
return false;
}
}
</script>


Its working fine now.
Please try the above coding.

Thanks & Regards,