How to find the name of the first input in form but exclude an input with the name '__RequestVerificationToken'









up vote
1
down vote

favorite












I know I can use the following statement to get the name of the first input field in a form, however the RequestVerificationToken happens to be the first input in the form so, how do I exclude this?



var fullName = $('#ForgotLoginForm').find('input').first().attr('name');









share|improve this question



















  • 1




    This RequestVerificationToken is an Id or that element has a specific attr?
    – Ele
    Nov 12 at 0:46











  • Yes, how do I exclude something with an id of "__RequestVerificationToken"?
    – Hank
    Nov 12 at 0:49














up vote
1
down vote

favorite












I know I can use the following statement to get the name of the first input field in a form, however the RequestVerificationToken happens to be the first input in the form so, how do I exclude this?



var fullName = $('#ForgotLoginForm').find('input').first().attr('name');









share|improve this question



















  • 1




    This RequestVerificationToken is an Id or that element has a specific attr?
    – Ele
    Nov 12 at 0:46











  • Yes, how do I exclude something with an id of "__RequestVerificationToken"?
    – Hank
    Nov 12 at 0:49












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I know I can use the following statement to get the name of the first input field in a form, however the RequestVerificationToken happens to be the first input in the form so, how do I exclude this?



var fullName = $('#ForgotLoginForm').find('input').first().attr('name');









share|improve this question















I know I can use the following statement to get the name of the first input field in a form, however the RequestVerificationToken happens to be the first input in the form so, how do I exclude this?



var fullName = $('#ForgotLoginForm').find('input').first().attr('name');






javascript jquery






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 2:30

























asked Nov 12 at 0:44









Hank

1,16121955




1,16121955







  • 1




    This RequestVerificationToken is an Id or that element has a specific attr?
    – Ele
    Nov 12 at 0:46











  • Yes, how do I exclude something with an id of "__RequestVerificationToken"?
    – Hank
    Nov 12 at 0:49












  • 1




    This RequestVerificationToken is an Id or that element has a specific attr?
    – Ele
    Nov 12 at 0:46











  • Yes, how do I exclude something with an id of "__RequestVerificationToken"?
    – Hank
    Nov 12 at 0:49







1




1




This RequestVerificationToken is an Id or that element has a specific attr?
– Ele
Nov 12 at 0:46





This RequestVerificationToken is an Id or that element has a specific attr?
– Ele
Nov 12 at 0:46













Yes, how do I exclude something with an id of "__RequestVerificationToken"?
– Hank
Nov 12 at 0:49




Yes, how do I exclude something with an id of "__RequestVerificationToken"?
– Hank
Nov 12 at 0:49












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Assuming this __RequestVerificationToken is an Id, use this selector input:not(#__RequestVerificationToken)






var fullName = $('#ForgotLoginForm')
.find('input:not(#__RequestVerificationToken)')
.first()
.attr('name');

console.log(fullName);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='ForgotLoginForm'>
<input id='__RequestVerificationToken' name='__RequestVerificationToken'>
<input id='ele' name='EleFromStack'>
</div>








share|improve this answer






















  • Typo apologies. Noticed that it was in the name attribute not id. How does that change things?
    – Hank
    Nov 12 at 3:15










  • Never mind got it, .not('input[name=__RequestVerificationToken]')
    – Hank
    Nov 12 at 3:22

















up vote
1
down vote













You can use the not selector:






$('#ForgotLoginForm').find('input').not('#__RequestVerificationToken').first().css('background', 'red');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="ForgotLoginForm">
<input id="__RequestVerificationToken" type="hidden" value="1">
<input id="a" name="b" value="c" />
<input id="d" name="e" value="f" />
</form>





In the above example I just set the background color on that input as red, but you can take the value of the name attribute just like in your question, using attr('name').






share|improve this answer






















  • Just saw that the attribute is 'name', not 'id', what would I need to adjust?
    – Hank
    Nov 12 at 2:28










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254706%2fhow-to-find-the-name-of-the-first-input-in-form-but-exclude-an-input-with-the-na%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










Assuming this __RequestVerificationToken is an Id, use this selector input:not(#__RequestVerificationToken)






var fullName = $('#ForgotLoginForm')
.find('input:not(#__RequestVerificationToken)')
.first()
.attr('name');

console.log(fullName);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='ForgotLoginForm'>
<input id='__RequestVerificationToken' name='__RequestVerificationToken'>
<input id='ele' name='EleFromStack'>
</div>








share|improve this answer






















  • Typo apologies. Noticed that it was in the name attribute not id. How does that change things?
    – Hank
    Nov 12 at 3:15










  • Never mind got it, .not('input[name=__RequestVerificationToken]')
    – Hank
    Nov 12 at 3:22














up vote
1
down vote



accepted










Assuming this __RequestVerificationToken is an Id, use this selector input:not(#__RequestVerificationToken)






var fullName = $('#ForgotLoginForm')
.find('input:not(#__RequestVerificationToken)')
.first()
.attr('name');

console.log(fullName);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='ForgotLoginForm'>
<input id='__RequestVerificationToken' name='__RequestVerificationToken'>
<input id='ele' name='EleFromStack'>
</div>








share|improve this answer






















  • Typo apologies. Noticed that it was in the name attribute not id. How does that change things?
    – Hank
    Nov 12 at 3:15










  • Never mind got it, .not('input[name=__RequestVerificationToken]')
    – Hank
    Nov 12 at 3:22












up vote
1
down vote



accepted







up vote
1
down vote



accepted






Assuming this __RequestVerificationToken is an Id, use this selector input:not(#__RequestVerificationToken)






var fullName = $('#ForgotLoginForm')
.find('input:not(#__RequestVerificationToken)')
.first()
.attr('name');

console.log(fullName);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='ForgotLoginForm'>
<input id='__RequestVerificationToken' name='__RequestVerificationToken'>
<input id='ele' name='EleFromStack'>
</div>








share|improve this answer














Assuming this __RequestVerificationToken is an Id, use this selector input:not(#__RequestVerificationToken)






var fullName = $('#ForgotLoginForm')
.find('input:not(#__RequestVerificationToken)')
.first()
.attr('name');

console.log(fullName);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='ForgotLoginForm'>
<input id='__RequestVerificationToken' name='__RequestVerificationToken'>
<input id='ele' name='EleFromStack'>
</div>








var fullName = $('#ForgotLoginForm')
.find('input:not(#__RequestVerificationToken)')
.first()
.attr('name');

console.log(fullName);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='ForgotLoginForm'>
<input id='__RequestVerificationToken' name='__RequestVerificationToken'>
<input id='ele' name='EleFromStack'>
</div>





var fullName = $('#ForgotLoginForm')
.find('input:not(#__RequestVerificationToken)')
.first()
.attr('name');

console.log(fullName);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='ForgotLoginForm'>
<input id='__RequestVerificationToken' name='__RequestVerificationToken'>
<input id='ele' name='EleFromStack'>
</div>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 at 1:01

























answered Nov 12 at 0:55









Ele

22.6k42044




22.6k42044











  • Typo apologies. Noticed that it was in the name attribute not id. How does that change things?
    – Hank
    Nov 12 at 3:15










  • Never mind got it, .not('input[name=__RequestVerificationToken]')
    – Hank
    Nov 12 at 3:22
















  • Typo apologies. Noticed that it was in the name attribute not id. How does that change things?
    – Hank
    Nov 12 at 3:15










  • Never mind got it, .not('input[name=__RequestVerificationToken]')
    – Hank
    Nov 12 at 3:22















Typo apologies. Noticed that it was in the name attribute not id. How does that change things?
– Hank
Nov 12 at 3:15




Typo apologies. Noticed that it was in the name attribute not id. How does that change things?
– Hank
Nov 12 at 3:15












Never mind got it, .not('input[name=__RequestVerificationToken]')
– Hank
Nov 12 at 3:22




Never mind got it, .not('input[name=__RequestVerificationToken]')
– Hank
Nov 12 at 3:22












up vote
1
down vote













You can use the not selector:






$('#ForgotLoginForm').find('input').not('#__RequestVerificationToken').first().css('background', 'red');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="ForgotLoginForm">
<input id="__RequestVerificationToken" type="hidden" value="1">
<input id="a" name="b" value="c" />
<input id="d" name="e" value="f" />
</form>





In the above example I just set the background color on that input as red, but you can take the value of the name attribute just like in your question, using attr('name').






share|improve this answer






















  • Just saw that the attribute is 'name', not 'id', what would I need to adjust?
    – Hank
    Nov 12 at 2:28














up vote
1
down vote













You can use the not selector:






$('#ForgotLoginForm').find('input').not('#__RequestVerificationToken').first().css('background', 'red');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="ForgotLoginForm">
<input id="__RequestVerificationToken" type="hidden" value="1">
<input id="a" name="b" value="c" />
<input id="d" name="e" value="f" />
</form>





In the above example I just set the background color on that input as red, but you can take the value of the name attribute just like in your question, using attr('name').






share|improve this answer






















  • Just saw that the attribute is 'name', not 'id', what would I need to adjust?
    – Hank
    Nov 12 at 2:28












up vote
1
down vote










up vote
1
down vote









You can use the not selector:






$('#ForgotLoginForm').find('input').not('#__RequestVerificationToken').first().css('background', 'red');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="ForgotLoginForm">
<input id="__RequestVerificationToken" type="hidden" value="1">
<input id="a" name="b" value="c" />
<input id="d" name="e" value="f" />
</form>





In the above example I just set the background color on that input as red, but you can take the value of the name attribute just like in your question, using attr('name').






share|improve this answer














You can use the not selector:






$('#ForgotLoginForm').find('input').not('#__RequestVerificationToken').first().css('background', 'red');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="ForgotLoginForm">
<input id="__RequestVerificationToken" type="hidden" value="1">
<input id="a" name="b" value="c" />
<input id="d" name="e" value="f" />
</form>





In the above example I just set the background color on that input as red, but you can take the value of the name attribute just like in your question, using attr('name').






$('#ForgotLoginForm').find('input').not('#__RequestVerificationToken').first().css('background', 'red');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="ForgotLoginForm">
<input id="__RequestVerificationToken" type="hidden" value="1">
<input id="a" name="b" value="c" />
<input id="d" name="e" value="f" />
</form>





$('#ForgotLoginForm').find('input').not('#__RequestVerificationToken').first().css('background', 'red');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="ForgotLoginForm">
<input id="__RequestVerificationToken" type="hidden" value="1">
<input id="a" name="b" value="c" />
<input id="d" name="e" value="f" />
</form>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 at 1:01

























answered Nov 12 at 0:56









Dekel

42.4k54567




42.4k54567











  • Just saw that the attribute is 'name', not 'id', what would I need to adjust?
    – Hank
    Nov 12 at 2:28
















  • Just saw that the attribute is 'name', not 'id', what would I need to adjust?
    – Hank
    Nov 12 at 2:28















Just saw that the attribute is 'name', not 'id', what would I need to adjust?
– Hank
Nov 12 at 2:28




Just saw that the attribute is 'name', not 'id', what would I need to adjust?
– Hank
Nov 12 at 2:28

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254706%2fhow-to-find-the-name-of-the-first-input-in-form-but-exclude-an-input-with-the-na%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3