You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gus Delgado <gd...@oceanobjects.com> on 2002/08/12 18:58:08 UTC

Validating with JavaScript

Is there a way to have the validation show on a JavaScript popup instead 
of on the header of the jsp?  I ask this a while back but I never got an 
answer.  

Thanks



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Validating with JavaScript

Posted by James Mitchell <jm...@telocity.com>.
Not very elegant, but here ya go......

I did this with the intent of getting each error msg on a newline, but my
split("\n") is doing what I want so this should get you started....


<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
Make sure you set errors.header and errors.footer to an empty string.  If
you use any html, it will show in your pop up box (quite ugly) unless you
filter it (you'll have to pay me to write that one for you;).
<br><br>
I hard-coded these for demonstration.
<div id="errors" style="display:none">
Password cannot be less than 3 characters.
Invalid username and/or password, please try again.
</div>

</BODY>
</HTML>
<SCRIPT LANGUAGE=javascript>
<!--

//********Warning, DHTML approaching **************
var divChar = "\n";
var errs = errors.innerHTML.split( divChar );
var txt = "";

for (var i=0; i < errs.length; i++)
{
    txt = txt + errs[i] + divChar;
}
alert(txt);

//-->
</SCRIPT>

James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://www.open-tools.org/struts-atlanta




> -----Original Message-----
> From: Gus Delgado [mailto:gdelgado@oceanobjects.com]
> Sent: Monday, August 12, 2002 12:58 PM
> To: Struts Users Mailing List
> Subject: Validating with JavaScript
>
>
> Is there a way to have the validation show on a JavaScript popup instead
> of on the header of the jsp?  I ask this a while back but I never got an
> answer.
>
> Thanks
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>