I have a JSP in a web application that works like this:  There is an esn text field where users enter in the 11 digits serial number.  The moment the field loses focus (onblur), it will call a javascript method and AJAX to do some backend check and validation on the serial number.  If the esn is valid, nothing occurs but if invalid, a javascript popup messages appears saying "ESN Invalid..."

Now though, there is a new requirement where instead of popup messages, they want the messages to be displayed on the actual web page above the esn text field in red (like an error message).  Same function is used here where when onblur, validation is performed and if invalid, message dynamically appears on the web page.  However, I am at a loss as to how to do this.  How do I make messages appear above esn field and dynamically when onblur occurs?  I mean, through javascript, I can only make popup messages appear...

This web application is not written using struts but has its own framework.  

Any samples, ideas?  

If you don't understand the question, I can clarify.
Who is Participating?
ksivananthConnect With a Mentor Commented:
girionisConnect With a Mentor Commented:
> I mean, through javascript, I can only make popup messages appear...

Not really. You should have the text inside a <div> or an iframe tag that you will show and hide onBlur, something like:

<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript">
window.onload = function()
      document.getElementById("afield").onblur = function()
            document.getElementById("adiv").innerHTML = document.getElementById("afield").value;
// --></script>
<input type="text" id="afield">
<div id="adiv"></div>

Hi girionis, this is what exactly in the link I have posted!
Hello ksivananth, I didn't look at your link when I posted. But now I am looking at it I can see that it is also talking about a div but it is not exactly the same, since I am using the onBlur() function while your link does not. Anyway, I am not here to steal points from you, so Magneto_Mystique if you go with the div solution please accept ksivananth's comment.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.