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

How to test if a variable is an array?

779


Tell me which function gives us the number of affected entries by a query?

757


Explain how to execute a php script using command line.

776


what is CURL?

780


What is filter_var?

707


What are the different types of PHP arrays?

803


What is psr in php?

801


What are the special characters you need to escape in single-quoted stings?

713


What is the difference between php and java?

727


How to create a table to store files?

745


Which framework is best for php?

730


Is php still in demand?

753


How can I convert ereg expressions to preg in php?

695


What is substr() in php? And how it is used?

745


How is a constant defined in a PHP script?

770