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>
PHP onsubmit in the form not going to the fuction.
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: PHP onsubmit in the form not going to the fuction.
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?
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.
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,
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,