In your form you have name and sur name but in the function you validating name and password due to which its giving password validation and redirecting to the same page so just add the password field in the form and it will work,