var UserAdd = function () {

    var initForm = function () {
        var initFormCtrl = function () {
            bindEvent();
        };


        var bindEvent = function() {
            $("#roleform").validate({
                rules: {
                	username: {
                        required: true,
                        htmlescape: true
                    },
                    password: {
                       
                        htmlescape: true
                    },
                    newpassword: {
                        htmlescape: true
                    }
                },
                messages: {
                	confirmNewPassword: {equalTo: "输入与上面相同的密码"},
                    password: {
                        htmlescape: "请您不要输入特殊字符!"
                    },
                    newpassword: {
                        htmlescape: "请您不要输入特殊字符!"
                    },
                    confirmNewPassword: {
                        htmlescape: "请您不要输入特殊字符!"
                    }
                },
                submitHandler: function (form) 
                {
                	var password;
                	var newpassword;
                	if($("#password").val()!=null&&$("#password").val()!='')
                	{
                		password = sha256_digest($("#password").val());
                	}
                	
                	if($("#confirmNewPassword").val()!=null && $("#confirmNewPassword").val()!='')
                	{
                		newpassword = sha256_digest($("#confirmNewPassword").val());
                	}
                    var formdata = 
                    {
                        password:password,
                        newpassword:newpassword
                    };
                   // console.log(formdata);
                    formSubmit(formdata);
                }
        }); }

        initFormCtrl();
    };

    return {

        //main function to initiate the module
        init: function () {
            initForm();
        }

    };

}();