Pressing enter for two seperate buttons

Hello everyone,

In front-end, I'm using two forms and each form has a button,  ie.. two buttons for two forms.

When I press enter, automatically the second button form is getting triggered since it is a default button.

What I want is, whenever I'm in a particular form only that button should get triggered. For example, if I'm editing some value in the first form only that form's button should get triggered and the same for the second form.

How can I achieve this in outsystems? 

Hi,

You should have the forms in separated web blocks, each one with its default button. This way, if I'm not wrong, the enter will use the next default button. Can't test right now.

Beware with the use of Client-side validation, as I "think" it will validate both forms (not sure here).

Cheers.

You could use javascript to identify which button to execute.

Something like this

<script>
$(function(){
    $('#"+YourFormA.Id+"').keypress(function (e){
        var key = e.which;
        if(key==13){
            $('#"+ButtonOfFormA.Id+"').click();
            return false;
        }
    });

    $('#"+YourFormB.Id+"').keypress(function (e){
        var key = e.which;
        if(key==13){
            $('#"+ButtonOfFormB.Id+"').click();
            return false;
        }
    });
});
</script>"