One problem is when you click the submit button.
For example if you write
when you click the link it will go to a1.
Replace the submit button with a normal one (type="button").
Other errors can be present but I think this is the problem.
Try to debug the code. Place alerts before and after every line from the function crypt and see if it gets there.