Added validation for password change page
Refactored some code in scripts file