Jump to content

Problems with "onblur"


careyd

Recommended Posts

Are there any special thoughts on using "onblur" with IE11?

 

I have the following code, between form tags, giving me problems - it doesn't goto the function script after data entry + a tab key (blur) or a mouse move. (blur).

 

<input name="verified" type=email tabindex="2" onblur="comparemail()">

 

Help for this newbie is appreciated.

Link to comment
Share on other sites

What does the comparemail() function do? I'm pretty sure the blur event should fire in IE11. There might be a Javascript error in your function.

Link to comment
Share on other sites

I don't believe the function gets triggered. I put an alert statement first to let me know the function executes and the alert statement does not run either.

Link to comment
Share on other sites

Its not dependant on mouse move but focus, for instance when clicking outside current focused element, then the item, which could be any item in browser, browser menu,etc or even outside the browser itself, whatever you clicked that would now gain the focus and causes the onblur to be triggered on element that loses that focus.

 

Anyhow just tested and had no problems with IE11 or any other browser.

Link to comment
Share on other sites

Thank Your for your analysis and response.

 

I have tested my code by:

 

1. entering data in the 1st input box and then pressing the tab key to move

to the next input box.

2. entering data in the 1st input box and then clicking the mouse on the next

input box

 

In each instance, I believe the onblur routine (comparemail) should have triggered

and did not. Instead the next input box took data without first executing my script.

 

The reason I do not believe my script ran is because the first expression in the

script is and alert box which did not appear.

 

I have attached the entire html page with the script and the input box for your review.

 

Thank You again for your assistance in advance.

 

Careyd

entry.html

Link to comment
Share on other sites

The JavaScript is WRONG! That does not work in any browser, never-mind IE11, that JavaScript is part JavaScript with a bit of html added, if you had checked the error console it would have pointed out the errors.

 

var entry1 == ""; BAD

var entry2 == ""; BAD

 

if entry1 == entry2 < /br>; EXTREMELY BAD!

else alert(" Bad email entries "); whhhattt? you need something to do for if condition before going to else and you need to separate these by curly brackets not merge together.

 

 

WAIT there's more

 

var entry1 = document.getElementById("entered"); BAD where is input with id ref of 'entered' i see only name attribute with that value.

var entry2 = document.getElementById("verified"); BAD where is input with id ref of 'verified' i see only name attribute with that value.

 

function comparemail(entered, verified) where are the arguments mentioned here?

 

MORE..

 

Multiple id ref for 'content', id should be unique within a single page.

 

you are not checking against the values with

var entry1 = document.getElementById("entered");

var entry2 = document.getElementById("verified");

 

just that they are HTMLInputElements meaning because they ARE BOTH HTMLInputElements they will always match.

Edited by dsonesuk
Link to comment
Share on other sites

Sorry, as explained, I am new at this.

 

Since you don't appear to have the patience to deal with my ineptitude,

I will go back to the books instead of this forum.

Link to comment
Share on other sites

If you can't be bothered to learn the basics, don't be surprised when we decide not to help fully, i mean did i not point out all the problems, what did you expect? Me to do the work for you.The browser console pointed out the errors mentioned, also you claimed it was just problem with IE11, when it was obivious that the code supplied would not work in any browser.

Link to comment
Share on other sites

DSONESUK:

 

Instead of airing your arrogance, try a bit of help.

 

If you were born smart (as you appear to think you were) congrats.

 

Don't exercise your ego here. It is supposed to be for help.

 

I got a VERY reasonable response from a moderator.

 

Don't send me anymore of your self-serving messages.

Link to comment
Share on other sites

LOOK just because you can't be bothered to learn to basics of javascript, don't go into hizzy fit when we don't just provide you with the corrected code just like that! ITS FOR YOU TO LEARN AND CORRECT THE MISTAKES, the reason the moderator was reasonable is that it is a well known fact that IE is very problematic compared with other better browsers, so the mod was willing to listen. But it came clear it was NOT IE problem at all but the mish-mash of of mistakes (or copy and paste) in your coding that shows you were attempting to paste bits and pieces of coding you have found and hoping it would work, NEWSFLASH! IT DOESN'T, none of your coding is related so there's no way to retrive, and carry out specific instructions cause you are targeting the wrong object properties.Did i not point out all your problems? (With coding, not you personally, i just know one problem with you, an inability to learn, with i'll just get someone else to do it instead attitude). So i did have patience to go through your code and point out the problems with it, it then was up to you to correct the errors, sorry for not having patience to do the work for you but then you would never learn anything but pass the buck.

Edited by dsonesuk
Link to comment
Share on other sites

I think the problem is the way you worded your post. You might need to work on your social skills.

 

I can't see how this could be interpretted as anything but an accusation:

The JavaScript is WRONG!

 

Comments like these naturally give people negative responses:

 

whhhattt?

BAD

EXTREMELY BAD!

 

This is obviously an attempt at ridicule:

 

WAIT there's more

 

Your subsequent posts did not make things any better by furthering your accusations and making more assumptions about the person.

 

I wouldn't jump to the conclusion that they have no interest in learning. Their negative response to your post was not due to that, but due to the fact that the wording of your post is extremely negative and accusatory in tone.

 

I wish for people to have a positive experience on the forums.

Link to comment
Share on other sites

'I can't see how this could be interpretted as anything but an accusation'Accusation? What? The code is wrong in every way FACT! Even though the problem was apparently only with IE11, but in FACT! it would not work in ANY browser, have you even looked at the code.?'Comments like these naturally give people negative responses:' The code was definitely not good, but very very bad, it would only be negative response if said person had made the attempt to study the basics of JavaScript for example if else condition, referencing id using getElementById(), but obviously the op had not. If the op had misplaced/misspelled character, bracket, parenthesis i would have showed what the correct code should be, but the code was WRONG in so many ways, like the op i could not be bothered.'This is obviously an attempt at ridicule:'Was not! That was what a irish comic (whose name evades me) catch phrase, meaning more to come, but in this case, more mistake found.

Link to comment
Share on other sites

MY APOLOGIES.

 

To Ingolmie: I did not intend to create a situation of conflict. Your observations are absolutely correct and drawing you into this "tempest in a teapot" is regrettable. I believed, when I made the first post, that this forum was to learn. By the time all was said and done, I had a severe case of "Enter Key Remorse". I did not help things by reacting to the flame I received. Again, my apologies.

 

To Dsonesuk: Your observations on the code are no doubt accurate. Your observations on my motivations, etc. are not. My apologies for offending your sense of sharing knowledge. I think it better that I seek a different forum to get the assistance I need to learn.

Link to comment
Share on other sites

It's probably best to write and test smallish lumps of code. Questions can then be focused on just a few problems. There are tutorials and references on this site and elsewhere.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>title</title><style>#mytext1,#mytext2 {width: 319px}</style><script>window.onerror = function(a, b, c){alert('Javascript Error:n'+a+'nURL: '+b+'nLine: '+c);return true;}</script><script>'use strict';window.onload = init;function init() {  document.getElementById('mytext1').onblur = compare1;  document.getElementById('form1').onsubmit = validate1;}function compare1() {  var entry1 = document.getElementById("mytext1").value;  var entry2 = document.getElementById("mytext2").value;  if (entry1==null || entry1==""){    alert("Missing entry1");  }else if (entry2==null || entry2==""){    alert("Missing entry2");  }else if (entry1 != entry2){    alert("Does not match");  }else{    alert("Match");  }}function validate1(e) {  e.preventDefault();  var entry1 = document.getElementById("mytext1").value;  var entry2 = document.getElementById("mytext2").value;  if (entry1=="" || entry2=="" || entry1!=entry2){    alert("validate failed");    return false;  }else{    alert("submitting...");    //document.getElementById("form1").submit();  }}</script></head><body><form method="post" id="form1" action="http://www.posttestserver.com/">   <input type="text" name="mytext1" id="mytext1" /><br/>  <input type="text" name="mytext2" id="mytext2" /><br/>  <input type="submit" value="Submit"/></form></body>    </html>
Link to comment
Share on other sites

Thank You for the assist. I will go back and experiment further.

 

I am, unfortunately, using Expression Web4 and should probably use something else to do entry/testing if anyone has a suggestion.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...