<a> tag in Html is Not Working in the form

时间:2017-10-29 12:47:30

标签: html forms

In my html form, there is a form submit ( ) button; beside that, there is also a button ( ) for back to previous page without editing any information. Just see below:

<form name="edit_profile_form" onsubmit="return EditProfileValidation();" method="post" action="user_info_save.php">

... 

// here text and radio fields to edit user profile info by the user.

...

    <div class="edit_profile_back_button">
        <a href="view_profile.php">
        <button class="back_to_profile"> Back to Profile Page </button>
        </a> 
    </div>

    <div class="edit_profile_save_record">
        <input type="submit" name="edit_profile_data_save" class="save_new_user_info" value="Save Record" /> 
    </div>

</form>

The problem is with the back button. When I click on the "Back to Profile Page" button, it submits the form to the user_info_save.php page instead of view_profile.php page.

Why the form behaviours like this ?

Kindly help me. Thanx in advance.

1 个答案:

答案 0 :(得分:2)

按钮类型属性的默认值为submit。 试试这个:

<button class="back_to_profile" type="button">Back to Profile Page</button>