You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by aum strut <au...@gmail.com> on 2008/12/09 19:37:00 UTC

Validating Autocompleter using javascript

Hi all,

i am struck in a simple problem but not able to proceed as i m unable to
find any solution for this. I am using struts2 UI tags and in order to
validate the user input i am using javascript for validation(Currently not
in a position to use validation frame work).

everything was going ok but now i have to use auocompleter and here
javascript validation is not working.i have created a seperated javascript
file and validating the user input using this file.

My javascript validation is working fine(even displaying errors) up to the
point it encounters autocompleter but it stops validating the input fields
after it.

below is the code i m using to validtate autocompleter:


<s:autocompleter name="addressPO.city" forceValidOption="true" theme="simple"
id="addressPO.city" cssClass="inputText" cssStyle="width:125px" list="{'Andaman
and Nicobar','Andhra Pradesh','Arunachal Pradesh','Assam'}"/>



and the code to validate this is:

document.getElementById('addressPO.city').value = document.getElementById(
'addressPO.city').value.trim();

if(document.getElementById('addressPO.city').value == null ||
document.getElementById('addressPO.city').value == "" )

{

alert("error");

}

following is the error Mozilla is showing to me

*Error: document.getElementById("addressPO.city") has no properties*

*
*Any suggestion for this are welcomed

Pleaes suggest me where i am doing wrong in order to validate this
autocomplete.

thanks in advance,

umesh

Re: Validating Autocompleter using javascript

Posted by Dave Newton <ne...@yahoo.com>.
Have you looked at the rendered HTML?

AFAIK you'd need to use the Dojo mechanisms for accessing Dojo component values.

Dave


--- On Wed, 12/10/08, aum strut <au...@gmail.com> wrote:

> From: aum strut <au...@gmail.com>
> Subject: Validating Autocompleter using javascript
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Wednesday, December 10, 2008, 11:48 AM
> Do any one have any suggestion regarding this problem or do
> i need to drop
> down the idea of using autocompleter???
> 
> Hi all,
> 
> i am struck in a simple problem but not able to proceed as
> i m unable to
> find any solution for this. I am using struts2 UI tags and
> in order to
> validate the user input i am using javascript for
> validation(Currently not
> in a position to use validation frame work).
> 
> everything was going ok but now i have to use auocompleter
> and here
> javascript validation is not working.i have created a
> seperated javascript
> file and validating the user input using this file.
> 
> My javascript validation is working fine(even displaying
> errors) up to the
> point it encounters autocompleter but it stops validating
> the input fields
> after it.
> 
> below is the code i m using to validtate autocompleter:
> 
> 
> <
> s:autocompleter name="addressPO.city"
> forceValidOption="true" theme="simple"
> id="addressPO.city"
> cssClass="inputText"
> cssStyle="width:125px" list="{'Andaman
> and Nicobar','Andhra Pradesh','Arunachal
> Pradesh','Assam'}"/>
> 
> 
> 
> and the code to validate this is:
> 
> document.getElementById(
> 'addressPO.city').value =
> document.getElementById('addressPO.city').value.trim();
> 
> 
> if(document.getElementById('addressPO.city').value
> == null ||
> document.getElementById('addressPO.city').value ==
> "" )
> 
> {
> 
> alert("error");
> 
> }
> 
> following is the error Mozilla is showing to me
> 
> *Error: document.getElementById("addressPO.city")
> has no properties*
> 
> *
> *Any suggestion for this are welcomed
> 
> Pleaes suggest me where i am doing wrong in order to
> validate this
> autocomplete.
> 
> thanks in advance,
> 
> umesh

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


Validating Autocompleter using javascript

Posted by aum strut <au...@gmail.com>.
Do any one have any suggestion regarding this problem or do i need to drop
down the idea of using autocompleter???

Hi all,

i am struck in a simple problem but not able to proceed as i m unable to
find any solution for this. I am using struts2 UI tags and in order to
validate the user input i am using javascript for validation(Currently not
in a position to use validation frame work).

everything was going ok but now i have to use auocompleter and here
javascript validation is not working.i have created a seperated javascript
file and validating the user input using this file.

My javascript validation is working fine(even displaying errors) up to the
point it encounters autocompleter but it stops validating the input fields
after it.

below is the code i m using to validtate autocompleter:


<
s:autocompleter name="addressPO.city" forceValidOption="true" theme="simple"
id="addressPO.city" cssClass="inputText" cssStyle="width:125px" list="{'Andaman
and Nicobar','Andhra Pradesh','Arunachal Pradesh','Assam'}"/>



and the code to validate this is:

document.getElementById(
'addressPO.city').value =
document.getElementById('addressPO.city').value.trim();


if(document.getElementById('addressPO.city').value == null ||
document.getElementById('addressPO.city').value == "" )

{

alert("error");

}

following is the error Mozilla is showing to me

*Error: document.getElementById("addressPO.city") has no properties*

*
*Any suggestion for this are welcomed

Pleaes suggest me where i am doing wrong in order to validate this
autocomplete.

thanks in advance,

umesh