Clear Username and password.

0
Hi, Could anyone please suggest as how I could clear the username or password fields when invalid username or password is entered using the login form widget.
asked
2 answers
1

I solved this in the following manner. Note that I use a custom login widget from the AppStore, but you should be able to edit the appropriate .js files in your theme.

You should find the piece of code for the response from sending the username and password (in my specific case this was LoginForm.js, in the standard theme it will be different). Note that the code below is not complete, there are more cases. I added the this.userInput.reset() and this.passInput.reset() commands.

switch(ioArgs.xhr.status) {
        case 200 :
            mendix.widget.hideTooltip();
            mx.login();
            break;
        case 400 :
            span.innerHTML = i18nmap.http401;
            this.userInput.reset();
            this.passInput.reset();
            break;
        case 401 :
            span.innerHTML = i18nmap.http401;
            this.userInput.reset();
            this.passInput.reset();
            break;

Furthermore, I added the reset function (in my specific case I added it to FormInput.js):

    reset : function() {
    this.node.value ="";
    this.showExample(); 
},
answered
0

Maybe replace the save-button with a microflow-button that does a commit.

On the commit-action set an error handler an in the error exit add a change action to clear the field and probably some validation feedback or error message action

answered