Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   STRUTS-<html:submit> -Hitting enter key does not submit the form (http://www.velocityreviews.com/forums/t878462-struts-html-submit-hitting-enter-key-does-not-submit-the-form.html)

Megha Vishwanath 07-18-2004 02:29 PM

STRUTS-<html:submit> -Hitting enter key does not submit the form
 
Hi,

I have a struts form <html:form> in which although the focus rests on
the submit button, hitting the enter key does not submit the form.

I tried capturing the Enter key event and followed it by the
document.form.submit() but this takes me through the validation
attached with the submit twice( giving me all the alerts twice).

Here's the code
function validate()
{

var validateVal = isValidated();//this guy does all the validation
if(!validateVal)
{
return false;
}
else
{
document.CustSearchFormBean.submit();
}

}

function checkKeyPressed()
{

if(window.event.keyCode=="13")
{

validate();
}
}

I call validate
a)for the enter button through <BODY onkeypress=checkKeyPressed();
b)for the mouseclick submit through <html:submit onclick=validate();


This may be a whole pointless workaround. Does Struts support
something more elegant?

Any solutions?


Thanks and Regards,
Megha

Wired Earp 07-19-2004 10:22 AM

Re: STRUTS-<html:submit> -Hitting enter key does not submit the form
 
Megha Vishwanath wrote:

> I have a struts form <html:form> in which although the focus rests on
> the submit button, hitting the enter key does not submit the form.
>
> I tried capturing the Enter key event and followed it by the
> document.form.submit() but this takes me through the validation
> attached with the submit twice( giving me all the alerts twice).
>
> Here's the code
> function validate()
> { var validateVal = isValidated();//this guy does all the validation
> ...
>
> I call validate
> a)for the enter button through <BODY onkeypress=checkKeyPressed();
> b)for the mouseclick submit through <html:submit onclick=validate();


Better rely on default form behavior where "enter" does actually submit the
form. Just like that. Try the "onsubmit" on the <form> tag like this:

<form action="?" method="?" onsubmit="return isValidated();">

And make sure that your <html:submit/> renders as <input type="submit"/> in
the real world. One might need to call function isValidated() with an
argument - as in sValidated(this) - or as a method of the form - like
this.isValidated(), check it out.

> This may be a whole pointless workaround. Does Struts support
> something more elegant?


Server side validation?


--
Wired Earp
Wunderbyte

Megha Vishwanath 07-20-2004 05:37 AM

Re: STRUTS-<html:submit> -Hitting enter key does not submit the form
 
I'm sorry , if you attempted to answer my query. I had a problem
completely unrelated to the <html:submit> or the java script function
shown.

I had a numeric lock on one of my fields that was not recognising the
"Enter" event.

Sorry again,

Megha.

Megha Vishwanath 07-20-2004 05:45 AM

Re: STRUTS-<html:submit> -Hitting enter key does not submit the form
 


I'm sorry , since you attempted to answer my query. I had a problem
completely unrelated to the <html:submit> or the java script function
shown.

I had a numeric lock on one of my fields that was not recognising the
"Enter" event.

Sorry again,

Megha.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT. The time now is 08:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57