How can we submit a form without a submit buttom?

Answer Posted / ram gopal verma

<script type="text/javascript">

function validateAndSubmit()
{
if(document.getElementById('user_id').value=='') {
alert('Please enter user id');
document.getElementById('user_id').focus();
}
else
if(document.getElementById('pass').value=='')
{
alert('Please enter password');
document.getElementById('pass').focus();
}else
{
document.form1.submit();
}
}
</script>

<form id="form1" name="form1" method="post" action="action.php" onsubmit="return validate()">

<input type="text" name="user_id" id="user_id" />
<input type="password" name="pass" id="pass" />

<a href="javascript:validateAndSubmit();">Submit Me..</a>

</form>

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 3 types of sessions?

539


In PHP, fgets() is used to read a file one line at a time. State Whether True or False?

580


Describe session in php.

533


Where are php configuration settings stored?

529


How can you upload a file using php?

551






What happens if an expected input field was not submitted?

527


How do I display php errors?

511


Which is not a php magic constant?

576


How the values are ordered in an array?

567


Tell me how would you declare a function that receives one parameter name hello?

532


How is it possible to set an infinite execution time for php script?

518


What are the uses of implode() function?

562


Do you know when sessions ends?

552


What is the difference between $argv and $argc? Give example?

504


What is fetch array in php?

573