javascript - if( x.substr(0, 5) == "live:") Not Working -
i don't know why code not working
if (x.substr(0, 5) == "live:") { document.getelementbyid("errmsg").innerhtml = "please remove "live:" press enter"; return false; }
totally using code given below:
if (x.substr(0, 1).match(/[a-za-z]/) == null) { document.getelementbyid("errmsg").innerhtml = "username starts letters"; return false; } if (x.substr(0, 5) == "live:") { document.getelementbyid("errmsg").innerhtml = "please remove "live:" press enter"; return false; }
so here, x.substr(0, 1)
working fine second step creating issue.
actually want put check first 5 letters if live: give error.
what missing?
the substring test working.
i believe have syntax error quotations. document.getelementbyid("errmsg").innerhtml = "please remove "live:" press enter";
should be
document.getelementbyid("errmsg").innerhtml = "please remove 'live:' press enter";
the " before live: ends string , causes compilation error, because js doesn't know live:.
Comments
Post a Comment