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');
javascript jquery
add a comment |
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');
javascript jquery
1
ThisRequestVerificationToken
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
add a comment |
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');
javascript jquery
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
javascript jquery
edited Nov 12 at 2:30
asked Nov 12 at 0:44
Hank
1,16121955
1,16121955
1
ThisRequestVerificationToken
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
add a comment |
1
ThisRequestVerificationToken
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
add a comment |
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>
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
add a comment |
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')
.
Just saw that the attribute is 'name', not 'id', what would I need to adjust?
– Hank
Nov 12 at 2:28
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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>
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
add a comment |
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>
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
add a comment |
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>
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>
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
add a comment |
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
add a comment |
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')
.
Just saw that the attribute is 'name', not 'id', what would I need to adjust?
– Hank
Nov 12 at 2:28
add a comment |
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')
.
Just saw that the attribute is 'name', not 'id', what would I need to adjust?
– Hank
Nov 12 at 2:28
add a comment |
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')
.
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>
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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