var LoginForm = function(){};

/***
 * Init the form
 * @returns {undefined}
 */
LoginForm.Init = function(){
    Event.AddById("btnSave", "click", LoginForm.SaveElement);
};

/***
* Get the Id of element 
*/
LoginForm.GetId = function(){
    return Form.GetId("LoginFormForm");
};

/*
* Save the Element
*/
LoginForm.SaveElement = function(e){
   
    if(Form.IsValid("LoginFormForm"))
    {
    let request = new Http("LoginForm", "SaveElement");
        request.SetData(Form.Serialize("LoginFormForm"));

        request.Post(data => {

            data = JSON.parse(data);

            if(data.status == "error"){
                Form.RenderError("LoginFormForm", data.data.message);
            } else{

                Form.SetId("LoginFormForm", data.data.Id);
            }
        });
    }
};

