Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display user error in form field

Status
Not open for further replies.

Everton1Blue

Technical User
Jun 6, 2014
41
GB
Hello

I have a small Web form Link that looks like this:

myForm_ipkens.jpg


When a user does not complete the form correctly, an error message appears on screen as follows:

result_bxrutz.jpg


That's because there is not enough room to display the error. The best way, I think, of resolving this issue is to display the error message in the form field itself, but how would I do that, please? The relevant code I have for the Name field, for example, is this:

Code:
[b]<p>[/b]<asp:Label ID="Name" Text="Name"></asp:Label>
<asp:TextBox ID="your_name"></asp:TextBox>[b]</p>[/b]
"RequiredFieldValidator1" controlToValidate="your_name" ForeColor="#FF6666" ErrorMessage="Please complete the Name field"></asp:RequiredFieldValidator>

Thanks for any help.
 
You would need to change the textbox's value property, or placeholder property to your error text so it displays inside it. However, something like this cannot be accomplished with HTML alone. You can either use Javascript or keep with your ASP code.

In either case, the solution would fall outside the scope of this forum.

Perhaps forum216 , or forum333 would be more appropriate.

At its most basic using JS, it would something like:
Code:
formObj,textboxObj.value="ERROR MESSAGE HERE";


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thanks, Vacunita

I'll post the same message in the ASP.NET/VB.NET forum (know nothing about JS!).

Thanks for pointing me in the right direction.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top