Zeeshan Rang
Zeeshan Rang

Reputation: 19885

How can I add an attribute with special character using DOJO

Getting an error trying to add an attribute aria-live, because of the special character in between.

How can I fix this?

dojo.ready(function(){

    dojo.connect(dojo.query("#buttonTest")[0],"onclick",function(evt){

        var fnameBox = dojo.byId("UPDATE_First_name_id").value;
        var lnameBox = dojo.byId("UPDATE_Last_name_id").value;

        if(fnameBox == ""){
            if(!dojo.byId("error_fname")){
                var xys1 =dojo.create("a",{title:"Error link", id:"error_fname", href: "#", class:"ibm-error-link", innerHTML:" "});              
                dojo.query("#UPDATE_First_name_id").after(xys1);

                var span1=dojo.create("span",{class:"ibm-access", aria-live:"assertive", role:"alert"});
                dojo.query("#error_fname").after(span1);
            }
        }
        else{
           dojo.destroy("error_fname");
        }

Thanks for help in advance.

Zeeshan

Upvotes: 0

Views: 196

Answers (1)

Craig Swing
Craig Swing

Reputation: 8162

Put the property names inside quotes. You will also need to do this with the class property, because class is a reserved word.

var xys1 =dojo.create("a", {  
     title:"Error link", 
     id:"error_fname", 
     href: "#", 
     "class": "ibm-error-link", 
     innerHTML:" "
});              


var span1=dojo.create("span",{
     "class":"ibm-access", 
     "aria-live":"assertive", 
     role:"alert"
});

Upvotes: 3

Related Questions