470,863 Members | 1,323 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,863 developers. It's quick & easy.

onblur combo box alert

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 7933
acoder
16,027 Expert Mod 8TB
Changed title of thread.
Feb 20 '07 #2
acoder
16,027 Expert Mod 8TB
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 100+
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
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 Expert Mod 8TB
Threads merged. You are posting on the same topic, so I have merged the threads.
Mar 6 '07 #6
acoder
16,027 Expert Mod 8TB
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 100+
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
thank u for ur valuable suggestion
Mar 7 '07 #9
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 Expert Mod 8TB
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 100+
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

Post your reply

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

Similar topics

1 post views Thread by Bartosz Wegrzyn | last post: by
2 posts views Thread by Bartosz Wegrzyn | last post: by
9 posts views Thread by Roger Withnell | last post: by
3 posts views Thread by Robert Oschler | last post: by
2 posts views Thread by Mathias Fritsch | last post: by
1 post views Thread by Mahesh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.