Try to search your question here, if you can't find : Ask Any Question Now ?

Trying to change text in a textbox on clicking away with blur

HomeCategory: stackoverflowTrying to change text in a textbox on clicking away with blur
craig asked 2 weeks ago

I’m sorry if this is too simple of a question. I am trying to change all instances of & to and using the event-handler blur. I am seeming to get no changes on blur even if my function is simply

id.value = "Random test string";

so I am assuming this is a problem with the event handler itself. Any help would be appreciated, thanks.

I have the code for changing & commented out because I was checking to see if the function tied to the blur eventhandler was triggering at all, which it was not. This code also has an HTML file with a text box with an ID of textid

 <script >
    //var for saving the string
    var textvar;
    //var for the texta area
    var id = document.getElementById("textid");
    id.addEventListener("blur", function() {

        //textvar = id.value;
        //textvar = textvar.replace("&", " and ");
        //id.value = textvar;

        textvar = "Correct!!";
        id.value = textvar;

    }, false);
 </script>
1 Answers
Best Answer
naveen answered 2 weeks ago
Your Answer

13 + 6 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com