Solved

error messages linked to the place where the user has to fill out the fields

Posted on 2004-04-05
6
131 Views
Last Modified: 2010-04-09
if i have a page for the user to submit some information and i have put some error messages in the beggining of the page in case the user forgets to fill out some text field,  how can i make those error messages directly linked to the place where the user has to fill out the fields ? I use html with ASP but java/vb script is also fine. It would be nice if when the user click on the error message, the mouse cursor appears directly in the field which the user has to fill in.
Thanks
0
Comment
Question by:Carl3003
  • 4
6 Comments
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10762394
Simple javascript/VB script is enough....


<script language="JavaScript">
var currentURL = window.location+"";
//alert(currentURL.value);
if (currentURL.indexOf("msg=") != -1)
{
  var qry=currentURL.split("=");
  var msg=qry[1];
  msg=msg.replace("%20"," ");
  document.write('<H2>Error  Message:' +msg+'</H2>');
}
</script>

<a href="?msg=Invliad data"> check errromsg </a>

for jumping into specific field,....
you can say...

formelement.focus();
0
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10762403
In asp,

<%

dim msg
msg  = request("msg")
Response.write "Error message = " & msg

%>

0
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10762411
for focus on an element....

<script>
function setfocus()
{
document.forms[0].searchcontent.focus();
}
</script>

<BODY onload=setfocus()>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Carl3003
ID: 10762786
I already have an error msg. I just need to know how to make a "key" word or picture after the error message which links me to the text/area field without the user need to scroll down. Little example would be very helpful and appreciated.
Thanks
0
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 150 total points
ID: 10763430
Make a hyper link of the error message as follows
<a href="#errorloc"> Error message </a>


and near the textbox or the filed where there is a error
include this tag..

<a name="errorloc">
<input type=text>
.
..
</a>
0
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 100 total points
ID: 10769509
If you want to focus back to the input field use this:
<div id="error1"
style="display:none;z-index:10;position:absolute;top:100px;left:100px;background-color:white;">
<a href="#" onClick="document.forms{'formname'].fieldname.focus()">
Your error message</a></div>

Then in the validation scripting when you find an error just add:
document.getElementById('error1').style.display='block';


Cd&
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question