Submit HTML form, perform javascript function (alert then redirect)

Submit HTML form, perform javascript function (alert then redirect)

<form action=javascript:completeAndRedirect();>
    <input type=text id=Edit1 
    style=width:280; height:50; font-family:Lucida Sans Unicode, Lucida Grande, sans-serif; font-size:22px>
</form>

Changing action to point at your function would solve the problem, in a different way.

You need to prevent the default behaviour. You can either use e.preventDefault() or return false; In this case, the best thing is, you can use return false; here:

<form onsubmit=completeAndRedirect(); return false;>

Submit HTML form, perform javascript function (alert then redirect)

Looks like your form is submitting which is the default behaviour, you can stop it with this:

<form action= method=post onsubmit=completeAndRedirect();return false;>

Leave a Reply

Your email address will not be published.