Common function added for Register/Login form