You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Wei, Mei" <Me...@isd.sccgov.org> on 2008/01/23 01:15:34 UTC

how to validate field right after the data is entered

Hi,

 

We want to validate the field data right after the data is entered. So
that the user can fix the error right away instead of waiting until the
whole form is submitted.

We thought that struts2 and ajax can help us on that. But what would be
the best way to do?

 

Any helps or guidance are appreciated.

 

Thanks,

Mei


RE: how to validate field right after the data is entered, HELP!

Posted by ravi_eze <ra...@ivycomptech.com>.
i dont think ull run into problems atleast as long as u reatain the theme as
ajax.

try using theme as simple and give onblur="validate(this);". Also include
the necessary .js files (make the necessary ajax configurations and view
source in browser, ull see the .js files). check if the .js files are being
served to the browser. (fire bug of mozilla would help u)

basically a new node <td> is created and error is written into it (addError
of validate.js)

function addError(e, errorText) {
    try {
        // clear out any rows with an "errorFor" of e.id
        var row = e.parentNode.parentNode;
        var table = row.parentNode;
        var error = document.createTextNode(errorText);
...

so this approach should resolve ur issues.

regards,
ravi 




Mei Wei wrote:
> 
> Thank you!! This is a really detailed document. I finally got this
> problem solved.
> But now I noticed that the javascript creates html nodes to display
> error message dynamically. If I changed the layout then it does not work
> well.
> For example, if I have 4 columns in the table to display two fields.
> Do you or anyone have any experience about this?
> 
> Thanks,
> Mei
> 
> -----Original Message-----
> From: ravi_eze [mailto:ravichandrac@ivycomptech.com] 
> Sent: Tuesday, January 22, 2008 9:04 PM
> To: user@struts.apache.org
> Subject: RE: how to validate field right after the data is entered,
> HELP!
> 
> 
> hi,
> 
> i solved the same problem this
> way:http://java-x.blogspot.com/2006/11/struts-2-validation.html Its ajax
> based validation. 
> 
> hope it helps.
> 
> cheers,
> ravi 
> 
> 
> 
> Mei Wei wrote:
>> 
>> Thanks, I looked at this document. I think it is more referring to 2.1
>> which does not have a stable release yet.
>> We prefer to use 2.0.11 since it is the latest stable release.
>> 
>> I was thinking about something like in the showcase example
> (quiz-ajax).
>> That we need to write a javascript function to listen to onblur()
> event
>> on the input text field. But I am not sure how to ask struts to
> validate
>> for this particular field, and how to get the error message back from
>> the response.
>> Can anyone help me on this?
>> 
>> Thanks,
>> Mei
>> 
>> -----Original Message-----
>> From: Martin Gainty [mailto:mgainty@hotmail.com] 
>> Sent: Tuesday, January 22, 2008 4:54 PM
>> To: Struts Users Mailing List
>> Subject: Re: how to validate field right after the data is entered
>> 
>> take a look at
>> 
>> http://struts.apache.org/2.x/docs/dojo-submit.html
>> for attributes validate
>> and 
>> ajaxValidation
>> 
>> M
>> ----- Original Message ----- 
>> From: "Wei, Mei" <Me...@isd.sccgov.org>
>> To: "Struts Users Mailing List" <us...@struts.apache.org>
>> Sent: Tuesday, January 22, 2008 7:15 PM
>> Subject: how to validate field right after the data is entered
>> 
>> 
>> Hi,
>> 
>>  
>> 
>> We want to validate the field data right after the data is entered. So
>> that the user can fix the error right away instead of waiting until
> the
>> whole form is submitted.
>> 
>> We thought that struts2 and ajax can help us on that. But what would
> be
>> the best way to do?
>> 
>>  
>> 
>> Any helps or guidance are appreciated.
>> 
>>  
>> 
>> Thanks,
>> 
>> Mei
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> 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/how-to-validate-field-right-after-the-data-is-ente
> red-tp15032110p15035015.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
> 
> ---------------------------------------------------------------------
> 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/how-to-validate-field-right-after-the-data-is-entered-tp15032110p15037370.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: how to validate field right after the data is entered, HELP!

Posted by "Wei, Mei" <Me...@isd.sccgov.org>.
Thank you!! This is a really detailed document. I finally got this
problem solved.
But now I noticed that the javascript creates html nodes to display
error message dynamically. If I changed the layout then it does not work
well.
For example, if I have 4 columns in the table to display two fields.
Do you or anyone have any experience about this?

Thanks,
Mei

-----Original Message-----
From: ravi_eze [mailto:ravichandrac@ivycomptech.com] 
Sent: Tuesday, January 22, 2008 9:04 PM
To: user@struts.apache.org
Subject: RE: how to validate field right after the data is entered,
HELP!


hi,

i solved the same problem this
way:http://java-x.blogspot.com/2006/11/struts-2-validation.html Its ajax
based validation. 

hope it helps.

cheers,
ravi 



Mei Wei wrote:
> 
> Thanks, I looked at this document. I think it is more referring to 2.1
> which does not have a stable release yet.
> We prefer to use 2.0.11 since it is the latest stable release.
> 
> I was thinking about something like in the showcase example
(quiz-ajax).
> That we need to write a javascript function to listen to onblur()
event
> on the input text field. But I am not sure how to ask struts to
validate
> for this particular field, and how to get the error message back from
> the response.
> Can anyone help me on this?
> 
> Thanks,
> Mei
> 
> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@hotmail.com] 
> Sent: Tuesday, January 22, 2008 4:54 PM
> To: Struts Users Mailing List
> Subject: Re: how to validate field right after the data is entered
> 
> take a look at
> 
> http://struts.apache.org/2.x/docs/dojo-submit.html
> for attributes validate
> and 
> ajaxValidation
> 
> M
> ----- Original Message ----- 
> From: "Wei, Mei" <Me...@isd.sccgov.org>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Tuesday, January 22, 2008 7:15 PM
> Subject: how to validate field right after the data is entered
> 
> 
> Hi,
> 
>  
> 
> We want to validate the field data right after the data is entered. So
> that the user can fix the error right away instead of waiting until
the
> whole form is submitted.
> 
> We thought that struts2 and ajax can help us on that. But what would
be
> the best way to do?
> 
>  
> 
> Any helps or guidance are appreciated.
> 
>  
> 
> Thanks,
> 
> Mei
> 
> 
> 
> ---------------------------------------------------------------------
> 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/how-to-validate-field-right-after-the-data-is-ente
red-tp15032110p15035015.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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: how to validate field right after the data is entered, HELP!

Posted by ravi_eze <ra...@ivycomptech.com>.
hi,

i solved the same problem this
way:http://java-x.blogspot.com/2006/11/struts-2-validation.html Its ajax
based validation. 

hope it helps.

cheers,
ravi 



Mei Wei wrote:
> 
> Thanks, I looked at this document. I think it is more referring to 2.1
> which does not have a stable release yet.
> We prefer to use 2.0.11 since it is the latest stable release.
> 
> I was thinking about something like in the showcase example (quiz-ajax).
> That we need to write a javascript function to listen to onblur() event
> on the input text field. But I am not sure how to ask struts to validate
> for this particular field, and how to get the error message back from
> the response.
> Can anyone help me on this?
> 
> Thanks,
> Mei
> 
> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@hotmail.com] 
> Sent: Tuesday, January 22, 2008 4:54 PM
> To: Struts Users Mailing List
> Subject: Re: how to validate field right after the data is entered
> 
> take a look at
> 
> http://struts.apache.org/2.x/docs/dojo-submit.html
> for attributes validate
> and 
> ajaxValidation
> 
> M
> ----- Original Message ----- 
> From: "Wei, Mei" <Me...@isd.sccgov.org>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Tuesday, January 22, 2008 7:15 PM
> Subject: how to validate field right after the data is entered
> 
> 
> Hi,
> 
>  
> 
> We want to validate the field data right after the data is entered. So
> that the user can fix the error right away instead of waiting until the
> whole form is submitted.
> 
> We thought that struts2 and ajax can help us on that. But what would be
> the best way to do?
> 
>  
> 
> Any helps or guidance are appreciated.
> 
>  
> 
> Thanks,
> 
> Mei
> 
> 
> 
> ---------------------------------------------------------------------
> 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/how-to-validate-field-right-after-the-data-is-entered-tp15032110p15035015.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: how to validate field right after the data is entered, HELP!

Posted by "Wei, Mei" <Me...@isd.sccgov.org>.
Thanks, I looked at this document. I think it is more referring to 2.1
which does not have a stable release yet.
We prefer to use 2.0.11 since it is the latest stable release.

I was thinking about something like in the showcase example (quiz-ajax).
That we need to write a javascript function to listen to onblur() event
on the input text field. But I am not sure how to ask struts to validate
for this particular field, and how to get the error message back from
the response.
Can anyone help me on this?

Thanks,
Mei

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Tuesday, January 22, 2008 4:54 PM
To: Struts Users Mailing List
Subject: Re: how to validate field right after the data is entered

take a look at

http://struts.apache.org/2.x/docs/dojo-submit.html
for attributes validate
and 
ajaxValidation

M
----- Original Message ----- 
From: "Wei, Mei" <Me...@isd.sccgov.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, January 22, 2008 7:15 PM
Subject: how to validate field right after the data is entered


Hi,

 

We want to validate the field data right after the data is entered. So
that the user can fix the error right away instead of waiting until the
whole form is submitted.

We thought that struts2 and ajax can help us on that. But what would be
the best way to do?

 

Any helps or guidance are appreciated.

 

Thanks,

Mei



---------------------------------------------------------------------
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: how to validate field right after the data is entered

Posted by Martin Gainty <mg...@hotmail.com>.
take a look at

http://struts.apache.org/2.x/docs/dojo-submit.html
for attributes validate
and 
ajaxValidation

M
----- Original Message ----- 
From: "Wei, Mei" <Me...@isd.sccgov.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, January 22, 2008 7:15 PM
Subject: how to validate field right after the data is entered


Hi,

 

We want to validate the field data right after the data is entered. So
that the user can fix the error right away instead of waiting until the
whole form is submitted.

We thought that struts2 and ajax can help us on that. But what would be
the best way to do?

 

Any helps or guidance are appreciated.

 

Thanks,

Mei



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org