Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Input[Name=""] not getting recognized on Firefox

I have a JavaScript code that reads the content of an html textbox and is working on IE and Chrome but is not being recognized by Firefox.

HTML Code:

<div id="SetInner_Form">                
    <form name="Set_Password" method="post" action="">
        Email Address &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input class="Auth" name="SetPwd_Username" type="text"/><br/><br/>
        New Password   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class="Auth" name="SetPwd_NewPwd" type="password"/><br/><br/>
        Retype Password &nbsp;<input class="Auth" name="SetPwd_RetypePwd" type="password"/><br/><br/>
        <div id="SetPwdResultWrapper">
            <div id="SetPwdResult" class="Validation_2"></div><br/>
        </div>
        <div id="RedirectLink" align="center" class="NoDisplay">Click <a href='https://localhost/webapp/index.aspx'>here</a> to go to main page</div><br/>
    </form>
    <div id="SetPwdBtnWrapper">
        <input id="SetPwdBtn" name="SetPwdBtn" type="submit" value="Confirm" align="center"/>
    </div>
    <img id="LoadingIcon_auth"/>
</div>

Javascript Code:

$("input[name=SetPwd_Username]").val()

Exception (on Firefox console):

Uncaught exception: Syntax error, unrecognized expression: input[name=SetPwd_Username

JQuery version is: jquery-1.6.4.min.js

The weird part is, Firefox can recognize the other html elements except for the SetPwd_Username

Am I missing something?

like image 450
ChiSen Avatar asked Dec 23 '13 02:12

ChiSen


1 Answers

Try putting the name of the field in single quotes.

$("input[name='SetPwd_Username']").val()
              ^ here          ^ and here
like image 67
Daniel A. White Avatar answered Oct 17 '22 08:10

Daniel A. White