stop submit request though "enter" from my form on Service Portal

omsa1
Kilo Guru

I found a workaround  but not sure how to apply it, where should i add this script.Please guide me. 

$j("form").bind("keypress", function (e) {
   
if (e.keyCode == 13) {
            e.preventDefault()
;
   
}
});

https://community.servicenow.com/community?id=community_question&sys_id=0a1f3e29db58dbc01dcaf3231f961901

If there is any other way to achieve this please let me know. Thanks. 

1 ACCEPTED SOLUTION

omsa1
Kilo Guru

Hi All,

Thanks for all the suggestions.

 

I achieved this by following PRB1189578,

1. This problem can be resolved by placing the input fields outside the form tag, this will prevent the form from being submitted on pressing enter.

View solution in original post

6 REPLIES 6

Bhagya Lakshmi
Mega Guru

Hello,

Add that script in Link function script in the widget.

function(scope,elem)

{

    $j("form").bind("keypress", function (e) {
    
if (e.keyCode == 13) {
            e.preventDefault()
;
    
}
});

}

Try once

Hi Bhagya Lakshmi,

 

Thanks for the reply. Are you saying add this in submit button widget , Link function option?

Hi Bhagya,

 

I tried but the option is read only. 

 

find_real_file.png

Hello,

Did you write that code or is that code exist already in link function option?