Reputation: 3769
How can i remove the property of required to the Second Element "Second Name" ?
Here is my Code :
<form action="#" novalidate>
First Name:
<input type="text" name="first" required>
Second Name :
<input type="text" name="second" required>
<input type="submit">
</form>
Upvotes: 0
Views: 3178
Reputation: 433
you can use the
removeAttribute command:
First set ID's for the inputs.
I set it to the same value as the name.
Next removeAttribute
document.getElementById("class").removeAttribute("required");
This should do the trick ;)
Here, have a fiddle:
Upvotes: 1
Reputation: 58432
Using jQuery you can do:
$('input[name=second]').prop('required', false);
Upvotes: 2
Reputation: 74738
Try this:
$('input[type="text"][name="second"]').prop('required', false);
it just removes the required property on the target element which has the name "second".
Upvotes: 1
Reputation: 18873
Try using .removeAttr().
$('input[name="class"]').removeAttr('required')
Upvotes: 1
Reputation: 7640
You can set required
property to false
$("input[name=class]").prop("required", false);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
Name: <input type="text" name="name" required>
Class: <input type="text" name="class" required>
<input type="submit">
</form>
Upvotes: 3