It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Help me.....onblur ()

Postby hazrizal84 on Wed Jun 11, 2008 1:38 am

ok..that's wat i want..thanx alot sir...thanx 4 ur help..is anythng, can i ask u again?..
hazrizal84
 
Posts: 22
Joined: Tue Jun 10, 2008 11:25 am

Postby rangana on Wed Jun 11, 2008 1:50 am

Yes. I could help, if I can.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby hazrizal84 on Wed Jun 11, 2008 2:52 am

sir, i've prob again....sory 4 disturbing u...
just wanna know, how can we modify the codes if we want the cursor to highlight the wrong answer after the error message box been popped up?..can u help me?..use the select() key rite?..but i don know how..
hazrizal84
 
Posts: 22
Joined: Tue Jun 10, 2008 11:25 am

Postby rangana on Wed Jun 11, 2008 2:57 am

Code: Select all
<script type="text/javascript">
window.onload=function()
{
   var inps=document.getElementsByTagName('input');
   for(var i=0;i<inps.length-1;i++)
      {
      inps[i].onblur=function()
         {
         if(this.value.indexOf('/')!=-1&&(this.value.length>1))
            {
         alert('Answers should either be number or slash only!\nNo Combination Please.');
         this.style.background='#fc0'; //replace with the color you wish
            }
         }
      }
}
</script>
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby hazrizal84 on Wed Jun 11, 2008 3:27 am

no sir..that's not what i mean...
after the message box appeared, i want to highligth the answer keyed in by user..so that, he/she can make the correction for that answer..the cursor wil remain at the answer keyed in, without move to the next textbox.
hazrizal84
 
Posts: 22
Joined: Tue Jun 10, 2008 11:25 am

Postby rangana on Wed Jun 11, 2008 3:51 am

...and what has the code above is doing?
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby hazrizal84 on Wed Jun 11, 2008 6:35 am

i've added this.select(); after the alert statement..but it doesn't work with mozilla firefox browser..can u help me?..
hazrizal84
 
Posts: 22
Joined: Tue Jun 10, 2008 11:25 am

Postby rangana on Wed Jun 11, 2008 6:48 am

What are you trying to achieve? Does'nt the code i've given you previously highlights the erroneous textbox? What's wrong with it. (I'm confused).
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby hazrizal84 on Wed Jun 11, 2008 10:33 am

the code you've given is actually highlight the textbox, not the answer entered. by adding this.select() after the alert statement, it works, it does highlight the answer and remain at the erroneous textbox, but it just works with I.E not mozilla firefox.. have you try with it?.. so, i want the code, so that it will work with both IE and mozilla firefox.
hazrizal84
 
Posts: 22
Joined: Tue Jun 10, 2008 11:25 am

Postby rangana on Thu Jun 12, 2008 12:04 am

Try focus() function. ;)

Btw, the best I could do is highlight the textbox.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Previous

Who is online

Users browsing this forum: No registered users and 5 guests