html - Javascript back button with confirm -


im trying implement button onto form designing when pressed results in confirmation popup allowing user select ok or cancel. code have button far follows.

function goback(){     window.history.back();     } <button type="back" value="back" onclick="goback()">back</button> 

the issue having elements of form set required, , therefore when button clicked, form asks fields completed first, please show me how button go without requesting form completed first. thanks

there no type="back" buttons. use:

<button value="back" onclick="goback()">back</button> 

or

<input type="button" onclick="goback()" value="back">  

or sure use link:

<a href="javascript:history.go(-1);">back</a> 

just don't use type="submit" , make sure don't have functions call form inputs validation when leave page!


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -