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
What is pdo classes?
What is the difference between array_map () and array_shift ()?
What is factory pattern in php?
Which have the fastest execution between mysql_fetch_array() and mysql_fetch_assoc()
Is php a backend?
Explain how is it possible to cast types in php?
What are include() and require() functions?
What are escaping characters? Explain with an example?
What does mvc stand for and what does each component do?
What is php explain how php works?
What is the use of curl()?
What is the purpose of php?
What is the difference between get and post in php?
What are traits?
How to redirect a url from http to https in .htaccess?