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
How to test if a variable is an array?
Tell me which function gives us the number of affected entries by a query?
Explain how to execute a php script using command line.
what is CURL?
What is filter_var?
What are the different types of PHP arrays?
What is psr in php?
What are the special characters you need to escape in single-quoted stings?
What is the difference between php and java?
How to create a table to store files?
Which framework is best for php?
Is php still in demand?
How can I convert ereg expressions to preg in php?
What is substr() in php? And how it is used?
How is a constant defined in a PHP script?