473,326 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Error alerts appear twice when pressing tab in input box

Hi,


I have a problem while validating form fields .

Here Iam explaining i have two text boxs with names in the html file

1 . first name and text box
2. second name and text box
3.submit
and here is my code
[HTML]<html>
<head>
<script>
function validate_clientprofilename()

{
var formObj = document.forms.nameFrm;

var name = /^[a-zA-Z]$/;


if(formObj.fname.value == ''){
alert("firstname should n't be Empty ");
formObj.fname.focus();
return true;

}

if(formObj.fname.value.match(name)) {
return true;}else{
alert("firstname accepts alphabets only");
formObj.fname.focus();
return false;
}
// formObj.first.value=code;
return false;
}
</script>
</head>
<body>
<form name='issueFrm' action="itself.html">
firstname<input type=text name='fname'>
<input type=text name='sname' onFocus="validate_clientprofilename();">
</form>
</body>
</html>
[/HTML]
actually working fine except alerting twice when i given tab

here is my problem

when i given tab with out entering or entering any special character other than letters . it is populating "alert message twice" but i want only once it should populate alert message please suggest me

thanking you.
Sep 4 '07 #1
6 2280
ak1dnar
1,584 Expert 1GB
Moved from Php articles section.
Sep 4 '07 #2
epots9
1,351 Expert 1GB
instead of using onfocus, try onblur. as soon are u enter that textbox you get an error since it empty.
Sep 4 '07 #3
acoder
16,027 Expert Mod 8TB
Please use CODE tags when posting code. Thanks!

Please use a good thread title.
Sep 4 '07 #4
acoder
16,027 Expert Mod 8TB
instead of using onfocus, try onblur. as soon are u enter that textbox you get an error since it empty.
Another possibility is onchange. onblur can sometimes occur unexpectedly.
Sep 4 '07 #5
epots9
1,351 Expert 1GB
Another possibility is onchange. onblur can sometimes occur unexpectedly.
You're right, i should of gave it alittle more thought i just was thinking the opposite (instead of entering it would do it on and exit).
Sep 4 '07 #6
acoder
16,027 Expert Mod 8TB
You're right, i should of gave it alittle more thought i just was thinking the opposite (instead of entering it would do it on and exit).
onblur
was obviously in the right direction.

There's another difference between onblur and onchange. onblur will fire any time tab is pressed. onchange will only fire when tab is pressed and there has been a change.
Sep 5 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Keiron Waites | last post by:
Ok to understand what I'm doing you'll have to load the HTML file attached (code also below): When you select an item on the left and select the ">>" button, some alerts will come up telling you...
15
by: Johan | last post by:
Hi, I've been working on the following piece of code and it works fine in IE and Opera, dut keep getting the same error in Firefox. Can anyone tell me what's wrong with this code? What I'm...
3
by: Serious_Practitioner | last post by:
Hello, all - A few days ago, I posted the following message - Hello all, and thank you for your help in the recent past. Got a new error message in the last few days. While working with...
1
by: Serious_Practitioner | last post by:
Good day - As you suggested, I got and used the right version of Jetcomp, and I also tried to run compact and repair a couple of times. I think that the compact and repair process doesn't fully...
5
by: Jonathan | last post by:
Hi-- I have the following code: #include <stdio.h> char a,b; int main()
3
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can...
3
by: Guig | last post by:
Hi, I have a problem with one of my form. I want to record some data in a table by using a form. One of those data it is the time and I want to use an input mask to be sure that everyone will...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.