You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2008/06/23 19:39:08 UTC
Re: Struts Validator Framework: client-side validation problem with
submitting buttons
Did you confirm whether calling the form's submit() method triggers its
onsubmit handler? It may be that calling submit() bypasses it, in which
case an explicit guard in your submit function might do the trick:
function submitRegistrazioneUtenteForm(nomeForm){
var form = ...;
if (validateRegistrazioneUtenteForm(form)) {
form.submit();
}
return false;
}
L.
cacodemon79 wrote:
> No suggestions? :(
>
> I also tried to use
> document.registrazioneUtenteForm.submit()")
> instead of
> eval("document."+nomeForm+".submit()")
> but the result is the same. The form is submitted but I can't see any
> javascript alerts.
>
> I can't understand where is the problem.
>
> I hope you can help me.
>
> Thanks.
>
>
>
> cacodemon79 wrote:
>> Hi, I'm using Struts Validator Framework (Struts 1.3).
>> Server-side validation works well.
>> The problem is in client-side validation.
>>
>> The form name I have to validate is: RegistrazioneUtenteForm.
>>
>> In my jsp page I have 2 buttons:
>> 1) <html:link
>> href="javascript:submitRegistrazioneUtenteForm('registrazioneUtenteForm')"><bean:message
>> key='form.submit'/></html:link>
>> 2) <html:submit />
>> and the following form declaration:
>> <html:form action="/registrazioneUtente" method="post" focus="username"
>> onsubmit="return validateRegistrazioneUtenteForm(this)">
>> Moreover I have enabled javascript validation:
>> <html:javascript formName="registrazioneUtenteForm" cdata="false" />
>>
>> The javascript function submitRegistrazioneUtenteForm is the following:
>> function submitRegistrazioneUtenteForm(nomeForm){
>> eval("document."+nomeForm+".submit()");
>> }
>>
>> If I click on the second button (html:submit), all works well (I get
>> javascript alerts).
>> If I click on the first button (html:link), the form is submitted but I
>> can't see any javascript alerts.
>>
>> I can't understand where is the problem.
>>
>> Can you help me?
>>
>> Thanks in advance.
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts Validator Framework: client-side validation problem with submitting buttons
Posted by Lukasz Lenart <lu...@googlemail.com>.
Hi,
2008/6/23 cacodemon79 <ca...@inwind.it>:
>
> Bingo!
> Now it works!
> Thanks a lot.
> However i can't understand why the onsubmit handler is not triggered by the
> submit() function!
>
Maybe it depends on Web Browser, did you try with others?
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts Validator Framework: client-side validation problem with
submitting buttons
Posted by cacodemon79 <ca...@inwind.it>.
Thank you very much.
Laurie Harper wrote:
>
> I did what I should have done in the first place and looked it up:
> Form.submit() is specified to *not* call the onsubmit handler, so this
> is the correct behaviour (and should be consistent across all browsers).
>
> When in doubt, check the documentation :-)
>
> L.
>
> cacodemon79 wrote:
>> Bingo!
>> Now it works!
>> Thanks a lot.
>> However i can't understand why the onsubmit handler is not triggered by
>> the
>> submit() function!
>>
>>
>> Laurie Harper wrote:
>>> Did you confirm whether calling the form's submit() method triggers its
>>> onsubmit handler? It may be that calling submit() bypasses it, in which
>>> case an explicit guard in your submit function might do the trick:
>>>
>>> function submitRegistrazioneUtenteForm(nomeForm){
>>> var form = ...;
>>> if (validateRegistrazioneUtenteForm(form)) {
>>> form.submit();
>>> }
>>> return false;
>>> }
>>>
>>> L.
>>>
>>> cacodemon79 wrote:
>>>> No suggestions? :(
>>>>
>>>> I also tried to use
>>>> document.registrazioneUtenteForm.submit()")
>>>> instead of
>>>> eval("document."+nomeForm+".submit()")
>>>> but the result is the same. The form is submitted but I can't see any
>>>> javascript alerts.
>>>>
>>>> I can't understand where is the problem.
>>>>
>>>> I hope you can help me.
>>>>
>>>> Thanks.
>>>>
>>>>
>>>>
>>>> cacodemon79 wrote:
>>>>> Hi, I'm using Struts Validator Framework (Struts 1.3).
>>>>> Server-side validation works well.
>>>>> The problem is in client-side validation.
>>>>>
>>>>> The form name I have to validate is: RegistrazioneUtenteForm.
>>>>>
>>>>> In my jsp page I have 2 buttons:
>>>>> 1) <html:link
>>>>> href="javascript:submitRegistrazioneUtenteForm('registrazioneUtenteForm')"><bean:message
>>>>> key='form.submit'/></html:link>
>>>>> 2) <html:submit />
>>>>> and the following form declaration:
>>>>> <html:form action="/registrazioneUtente" method="post"
>>>>> focus="username"
>>>>> onsubmit="return validateRegistrazioneUtenteForm(this)">
>>>>> Moreover I have enabled javascript validation:
>>>>> <html:javascript formName="registrazioneUtenteForm" cdata="false" />
>>>>>
>>>>> The javascript function submitRegistrazioneUtenteForm is the
>>>>> following:
>>>>> function submitRegistrazioneUtenteForm(nomeForm){
>>>>> eval("document."+nomeForm+".submit()");
>>>>> }
>>>>>
>>>>> If I click on the second button (html:submit), all works well (I get
>>>>> javascript alerts).
>>>>> If I click on the first button (html:link), the form is submitted but
>>>>> I
>>>>> can't see any javascript alerts.
>>>>>
>>>>> I can't understand where is the problem.
>>>>>
>>>>> Can you help me?
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Struts-Validator-Framework%3A-client-side-validation-problem-with-submitting-buttons-tp18042962p18093853.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts Validator Framework: client-side validation problem with
submitting buttons
Posted by Laurie Harper <la...@holoweb.net>.
I did what I should have done in the first place and looked it up:
Form.submit() is specified to *not* call the onsubmit handler, so this
is the correct behaviour (and should be consistent across all browsers).
When in doubt, check the documentation :-)
L.
cacodemon79 wrote:
> Bingo!
> Now it works!
> Thanks a lot.
> However i can't understand why the onsubmit handler is not triggered by the
> submit() function!
>
>
> Laurie Harper wrote:
>> Did you confirm whether calling the form's submit() method triggers its
>> onsubmit handler? It may be that calling submit() bypasses it, in which
>> case an explicit guard in your submit function might do the trick:
>>
>> function submitRegistrazioneUtenteForm(nomeForm){
>> var form = ...;
>> if (validateRegistrazioneUtenteForm(form)) {
>> form.submit();
>> }
>> return false;
>> }
>>
>> L.
>>
>> cacodemon79 wrote:
>>> No suggestions? :(
>>>
>>> I also tried to use
>>> document.registrazioneUtenteForm.submit()")
>>> instead of
>>> eval("document."+nomeForm+".submit()")
>>> but the result is the same. The form is submitted but I can't see any
>>> javascript alerts.
>>>
>>> I can't understand where is the problem.
>>>
>>> I hope you can help me.
>>>
>>> Thanks.
>>>
>>>
>>>
>>> cacodemon79 wrote:
>>>> Hi, I'm using Struts Validator Framework (Struts 1.3).
>>>> Server-side validation works well.
>>>> The problem is in client-side validation.
>>>>
>>>> The form name I have to validate is: RegistrazioneUtenteForm.
>>>>
>>>> In my jsp page I have 2 buttons:
>>>> 1) <html:link
>>>> href="javascript:submitRegistrazioneUtenteForm('registrazioneUtenteForm')"><bean:message
>>>> key='form.submit'/></html:link>
>>>> 2) <html:submit />
>>>> and the following form declaration:
>>>> <html:form action="/registrazioneUtente" method="post" focus="username"
>>>> onsubmit="return validateRegistrazioneUtenteForm(this)">
>>>> Moreover I have enabled javascript validation:
>>>> <html:javascript formName="registrazioneUtenteForm" cdata="false" />
>>>>
>>>> The javascript function submitRegistrazioneUtenteForm is the following:
>>>> function submitRegistrazioneUtenteForm(nomeForm){
>>>> eval("document."+nomeForm+".submit()");
>>>> }
>>>>
>>>> If I click on the second button (html:submit), all works well (I get
>>>> javascript alerts).
>>>> If I click on the first button (html:link), the form is submitted but I
>>>> can't see any javascript alerts.
>>>>
>>>> I can't understand where is the problem.
>>>>
>>>> Can you help me?
>>>>
>>>> Thanks in advance.
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts Validator Framework: client-side validation problem with
submitting buttons
Posted by cacodemon79 <ca...@inwind.it>.
Bingo!
Now it works!
Thanks a lot.
However i can't understand why the onsubmit handler is not triggered by the
submit() function!
Laurie Harper wrote:
>
> Did you confirm whether calling the form's submit() method triggers its
> onsubmit handler? It may be that calling submit() bypasses it, in which
> case an explicit guard in your submit function might do the trick:
>
> function submitRegistrazioneUtenteForm(nomeForm){
> var form = ...;
> if (validateRegistrazioneUtenteForm(form)) {
> form.submit();
> }
> return false;
> }
>
> L.
>
> cacodemon79 wrote:
>> No suggestions? :(
>>
>> I also tried to use
>> document.registrazioneUtenteForm.submit()")
>> instead of
>> eval("document."+nomeForm+".submit()")
>> but the result is the same. The form is submitted but I can't see any
>> javascript alerts.
>>
>> I can't understand where is the problem.
>>
>> I hope you can help me.
>>
>> Thanks.
>>
>>
>>
>> cacodemon79 wrote:
>>> Hi, I'm using Struts Validator Framework (Struts 1.3).
>>> Server-side validation works well.
>>> The problem is in client-side validation.
>>>
>>> The form name I have to validate is: RegistrazioneUtenteForm.
>>>
>>> In my jsp page I have 2 buttons:
>>> 1) <html:link
>>> href="javascript:submitRegistrazioneUtenteForm('registrazioneUtenteForm')"><bean:message
>>> key='form.submit'/></html:link>
>>> 2) <html:submit />
>>> and the following form declaration:
>>> <html:form action="/registrazioneUtente" method="post" focus="username"
>>> onsubmit="return validateRegistrazioneUtenteForm(this)">
>>> Moreover I have enabled javascript validation:
>>> <html:javascript formName="registrazioneUtenteForm" cdata="false" />
>>>
>>> The javascript function submitRegistrazioneUtenteForm is the following:
>>> function submitRegistrazioneUtenteForm(nomeForm){
>>> eval("document."+nomeForm+".submit()");
>>> }
>>>
>>> If I click on the second button (html:submit), all works well (I get
>>> javascript alerts).
>>> If I click on the first button (html:link), the form is submitted but I
>>> can't see any javascript alerts.
>>>
>>> I can't understand where is the problem.
>>>
>>> Can you help me?
>>>
>>> Thanks in advance.
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Struts-Validator-Framework%3A-client-side-validation-problem-with-submitting-buttons-tp18042962p18075348.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org