first of all use onsubmit-function in a form
it looks like: <form onsubmit="a(event);">
then you change your function to:
Then it should work.
You have to try this on your local machine because sololearn playground won't allow redirects