Sharpharp1
Apprentice

Stop the ENTER Key Saving a record?

Hi,

 

Apologies for all the questions lately, editable lists are tricky.

 

Ok, on an editable list, i hide all the Toolbar buttons and have a seperate SAVE button in the Row column. This SAVE button saves the record but also i have an advanced condition which checks to ensure all fields have data in BEFORE the save method occurs, if field incomplete i pop up a message to the user and stop rule execution so the record is not saved. -This works fine.

 

However, i just found out that if a User hits the ENTER KEY on the Keyboard it bypasses my Column SAVE button and saved the record (including any incomplete fields)

 

How in the world of K2 can you stop the Keyboard ENTER key bypassing the Form Buttons?

 

OR i it possible for the ENTER key to execute my column SAVE button rules instead or whatever it is doing now?

 

 

0 Kudos
Reply
5 Replies
AhmadAbdullah
Apprentice

Re: Stop the ENTER Key Saving a record?

Dear,

 

i dont have the solution, but i have an approach u might wanna search for and try.

 

check for a javascript/jquery function to disable ENTER key presskey for your form/html... this should help.

and have it inside an expression data label with literal checked.

 

Regards.

0 Kudos
Reply
K2CaveMen
Apprentice

Re: Stop the ENTER Key Saving a record?

What you need to have is some validation..... 

 

Yes K2 have some out of the box validation... which are handy and can be added fairly easy... 

 

When Button Save is clicked... 

    Validation.... if the View passes validaiton Configure.... then check the checkbox for the fields to validate.

 

HOWEVER: This works great in an Item view... which is 1 record, for a List view you have an array or list of records... perhaps only will work on the current selected.

 

So what we do is to get help prior to that to execute a Magic Outobound Rule... this basically loops trough all the items on the list and validate.... If something is missing will popup and stop rule exectution. This way you always have the assurance that data is complete.

 

4990i9632DB13A681170F.jpg

 

You can reuse teh same Validation Outbound Rule when Create or Update... and you will be good to go. unless all the fields are exactly the way you want it the form will submit.

 

Hope this helps Happy Friday !!!.

 

Dinooz

 

Reply
Sharpharp1
Apprentice

Re: Stop the ENTER Key Saving a record?

Hi all,

 

Thanks for the suggestions:

 

I found this javascript: http://webcheatsheet.com/javascript/disable_enter_key.php

added it to a Data Label with Literal ticked, but pressing enter still works...

 

Any ideas if the script needs adapting for K2?

0 Kudos
Reply
Sharpharp1
Apprentice

Re: Stop the ENTER Key Saving a record?

Hi Caveman,

 

I had a look at your suggestion, can i ask what you configured for the "If view passed Validation". Did you tick the Validate fields for the List display rows only?

Do i need to tick the required boxes as well or not?

 

I created the subrule exactly like you said, however on the form if a User presses ENTER on the Keyboard, it bypasses all this and SAVES it....

 

Also, on the submit button, i get it to go the SAVE Toolbar button rule (which validation), but i keep getting the Send Message box even all the fields are complete..

 

Any ideas?

 

In the bit where you say "For all Rows" , is this looking on the current list view or the Smartobject Data? The data is not saved until it passes validation.

 

Looking at my list view now, i have entered two rows of data and clicked SAVE. But still get the pop-up message.....

By subrule 100% has all the fields i want checked to see whether they are empty

 

0 Kudos
Reply
Sharpharp1
Apprentice

Re: Stop the ENTER Key Saving a record?

I tried this ENTER capturing javascript, but still no joy:

 
<script type="text/javascript">
    function submitonenter(formid,evt,thisObj) {
        evt = (evt) ? evt : ((window.event) ? window.event : "")
        if (evt) {
            // process event here
            if ( evt.keyCode==13 || evt.which==13 ) {
                thisObj.blur();
                document.getElementById(formid).submit();
            }
        }
    }
</script>
 
Any ideas guys?
 
For starters, what Rule or event is the ENTER KEY doing when it added a row without validation?
0 Kudos
Reply