How to find two default submit buttons when i press the Enter key in asp.net using jquery?

I have two default submit button in a single web page.. one is in the main form.. and another one button is inside a div control.. this div control will be popup at login button click event.. so when i popup this div.. this div has a submit button and when i press enter key.. this button needs to submit.. if this div is closed.. i press enter key the main form submit button need submit the values.. how can i find the two submit buttons on enter key press even using jquery? please help. Thank you..

Answers


When the popup shows up, set the focus to the submit button of the popup div:

$('div.popupclass').find('button[type="submit"]').focus();

And, when the popup is closed, switch the focus back to the main form:

$('body').find('button[type="submit"]').focus();

if you are using jQuery-UI's dialog, then put those lines in the open: and close: calls.


Need Your Help

C# Color Blend and calculating opacity / alpha like Photoshop

c# image-processing photoshop alpha blending

I have an image I'm trying to process into a very specific look. I found a tutorial in Photoshop and have been slowly, step by step, recreating the Photoshop effects. The latest one is a color blen...

How to get a binded key not to type into Entry box

python python-3.x tkinter diacritics tkinter-entry

I have a program in which I want to type in, for example, ĝ when g^ is typed in an Entry box. I have got the ĝ to appear, but seem unable to rid the entry box of the ^ that has been typed in (yes, ...