| Viewed 89 times

How to prevent a form from being submitted


How to prevent a form from being submitted

1 Answer
Mohammad Qandeel
Answered
8

It's easy to do that just you need to add onsubmit="return false;"  to the form elements 

Example 

<form onsubmit="return false;">
    <div>
        <input type="text" >
    </div>
    <div>
        <input type="submit">
    </div>
</form>

another way to prevent a form from being submitted is to add onclick="return false;" to the submit button elements

Example 

<form>
    <div>
        <input type="text" >
    </div>
    <div>
        <input type="submit" onclick="return false;">
    </div>
</form>