The problem that I’m having is that my code works fine in JavaScript but doesn’t work correctly in Firefox or safari and wondering why. What I’m doing is I have a loop going through each element and depending on the variable inside a text box just want to alert something. Like i said earlier this code works fine in IE. Here is the code below:
Here is an example of text box:
<asp:TextBox ID="txtMac" runat="server" req="yes" errMessage="Mac"/>
for (a = 0; a < theForm.elements.length; a++) {
if (theForm.elements[a].type == "text" && theForm.elements[a].req == "yes") {
alert("Made it here")
}
}
Use getAttribute to read the custom attributes. See http://jsfiddle.net/8EWQr/.
So instead of
(theForm.elements[a].type == “text” && theForm.elements[a].req == “yes”)
use
(theForm.elements[a].getAttribute(‘type’) == “text” && theForm.elements[a].getAttribute(‘req’) == “yes”)