473,503 Members | 9,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onblur combo box alert

29 New Member
Helo i am going through the validations of date of birth in form
which consists of three combo boxes dd/mm/yyyy. My aim is to use onblur function through which i hav to call a function. And the content of that function should display an alert message when ever the field is empty or when the starting index element i.e. select month or select date or select year is selected. So when we press the tab by selecting any of the three above i hav to get an alert box.
Hope u will help me.
Feb 20 '07 #1
11 8130
acoder
16,027 Recognized Expert Moderator MVP
Changed title of thread.
Feb 20 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
Helo i am going through the validations of date of birth in form
which consists of three combo boxes dd/mm/yyyy. My aim is to use onblur function through which i hav to call a function. And the content of that function should display an alert message when ever the field is empty or when the starting index element i.e. select month or select date or select year is selected. So when we press the tab by selecting any of the three above i hav to get an alert box.
Hope u will help me.
Welcome to The Scripts.

Post the code you have so far. So you want this behaviour whatever the value of the combo box? For that just pass the combo object to the function and use:
Expand|Select|Wrap|Line Numbers
  1. alert(this.value);
In fact, you could even use:
[HTML]<select ... onblur="alert(this.value);">[/HTML] as long as you have set the value for each option.
Feb 20 '07 #3
Logician
210 New Member
Helo i am going through the validations of date of birth in form
which consists of three combo boxes dd/mm/yyyy. My aim is to use onblur function through which i hav to call a function. And the content of that function should display an alert message when ever the field is empty or when the starting index element i.e. select month or select date or select year is selected. So when we press the tab by selecting any of the three above i hav to get an alert box.
Hope u will help me.
If I understand correctly, I think this may do what you want: Link
Rather less obtrusive than a conventional alert.
Feb 20 '07 #4
prakashsurya
29 New Member
Hello gud evng
I am having a small problem
I am using three combo boxes for date of birth
I wanna know how to use the onchange function in this combo boxes
my aim is i hav to display some alert boxes when the user doesnt select anything or he has selected the first option i.e. Enter Date or Enter Month or Enter Year respectively.
Hope u vl help me
waiting for ur reply
Mar 6 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
Threads merged. You are posting on the same topic, so I have merged the threads.
Mar 6 '07 #6
acoder
16,027 Recognized Expert Moderator MVP
You have two options that I would suggest to validate this.

One is to call onblur, but not an alert box, but just an error message next to the boxes.

The second option is to call the validation function on focus of the next element (as long as they have been on the date select boxes first). You can do this by setting a variable onfocus of the day select dropdown. Then onfocus of the element after the date dropdown, call the validation function (if the variable is set).

Those are just two options to make it less obtrusive and more convenient for the user.

With regards to the checking, just check if selectedIndex is 0.
Mar 6 '07 #7
gauravgmbhr
107 New Member
well there are number of ways to have such a alert message
u can use the onChange event instead of OnBlur.



set the "select day", "select month"..... value Equal to 0

Onchange=someFunction(this)


Expand|Select|Wrap|Line Numbers
  1. function someFunction(obj) 
  2. {
  3.     if(obj.options[obj.selectedIndex].value==0 || obj.options[obj.selectedIndex].text=="")    {
  4. alert('field cannot be blank');
  5.  
  6. }//end if
  7. }//end function
  8.  
Mar 6 '07 #8
prakashsurya
29 New Member
thank u for ur valuable suggestion
Mar 7 '07 #9
prakashsurya
29 New Member
thank u
but here i am asking about onchange
can u please tell me how to use that one
and the properties of that function
waiting for ur reply
Mar 7 '07 #10
acoder
16,027 Recognized Expert Moderator MVP
onchange is just the same. Just call a function which checks for the value of the date dropdown field. If the selectedIndex is 0, then show an error message:
[HTML]<select id="..." name="..." onchange="checkDate(this)">[/HTML]
then in checkDate:
Expand|Select|Wrap|Line Numbers
  1. function checkDate(obj) {
  2. if (obj.selectedIndex == 0) // display error message...
  3. ...
  4. }
Just one problem with onchange is that the user might accidentally select the first item - that is why you don't want to display an alert (might be annoying).
Mar 7 '07 #11
gauravgmbhr
107 New Member
thank u
but here i am asking about onchange
can u please tell me how to use that one
and the properties of that function
waiting for ur reply

THERE IS A THING CALLED DOM(Document Object Model)
DOM tell u how to refer to each elemnt on the html page using java script
If u wanna read bout DOM try HTML DOM


THIS WILL LET U KNOW WHAT I DID IN THE FUNCTION
AND onchange works the same way as the Onblur

if u r using a div or select just use <select name="something" id="something" onchange="some_javascript_function()"></select>
Mar 7 '07 #12

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

Similar topics

1
4245
by: Bartosz Wegrzyn | last post by:
I do validate my form using onblur() event. In my example I have 3 fields in my form. name,address and city. I call my functions using onblur()="isname(this)" ...etc. My probllem is that when I...
2
12972
by: Bartosz Wegrzyn | last post by:
I use onblue event to validate fields in my form. I do this onblur="return isname()" and so so ... I have one form with 20 fields. My problem is that when the focus is for example on the...
10
6696
by: CES | last post by:
All, I'm having a problem returning focus back to an input field in Netscape. The code works in IE and Opera but not in netscape6+. Basically I have a function that is called upon...
9
3691
by: Roger Withnell | last post by:
Tearing hair out time! Simple attached page shows the problem. http://www.brilley.co.uk/TestFocusSelect.htm Using a function to test if too many characters have been keyed in to a textarea....
3
8907
by: Robert Oschler | last post by:
I have a textarea element that I have created an onblur() handler for. In the onblur() handler, I check to make sure that they have saved the contents of the edit box, before leaving it. If...
2
11578
by: Mathias Fritsch | last post by:
I try to run the following code, but no onblur/onfocus events happen. Is onfocus/onblur implemented in ie/firefox? <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <form>...
1
1853
by: Mahesh | last post by:
Hi all, Can any one advice what can be a work around here? When i run the code below, its showing the alert msg twice onfocus out of tf1 Thanks in advance, Maheshkumar <html>
3
1324
by: empiresolutions | last post by:
i am using the following AJAX request method. Most of you probably use this script allready as it seems to be everywhere online. I use it often with out issue... until now. What I'm finding is...
1
2592
by: Duncan | last post by:
Hi all, I'm tearing my hair out on this! I have a simple ASP.NET 2 page with a TextBox control, in the PreRender I set ClientSide events:- Response.Attributes.Add("onchange",...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.