• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Error Messages on a web form

Hi Everyone,

I need to place error messages on fields when they are left blank and they are required and must be numeric or alphabetic characters.

Where do I place an error message on say the Driver License Number left blank.  I know I can place messages when I try to add the record on an event button "ADD New", but I want the message to appear if the user selects enter or tabs to the next field or when the field loses focus.  Where do I do this.  I tried to do it in the textChanged event of the field, but the message does not appear when I select enter or tab to the next field.

jjc9809
0
jjc9809
Asked:
jjc9809
1 Solution
 
Lalit ChandraCommented:
you can try the below technique to solve your problem

<script>
function emailcheck(){
var string1=document.example.email.value
if (string1.indexOf("@")==-1){
.alert("Please input a valid email address!")
.document.example.email.focus()
.}
}
</script>

<form name="example"><input type="text" size="20" name="email" onblur="emailcheck()">
<strong>Feedback please:</strong>
<textarea name="S1" rows="2" cols="20"></textarea>
<input type="submit" name="B1" value="Submit">
</form>
0
 
Paul JacksonCommented:
PLease have a look at the linked article which describes using validation controls in asp.net, these controls check validation on the server side but also can be enabled to check validation on the clientside such as when leaving a field.

Vaidating USer INput in ASP.Net

Client-Side validation for asp.net Server-Controls
0

Featured Post

Independent Software Vendors: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now