JQuery.Validate only validates first field [duplicate]
This question already has an answer here:
validating multiple textbox having same name with jquery validator validates only first input
4 answers
.valid() only validates first input with jQuery Validation plugin
1 answer
I've been struggling all day with a JQuery validate issue. Where it only validates the first field.
I've managed to reproduce it here:
$(document).ready(function() {
$('#go').click(function() {
console.log('go clicked');
if ($('#detailsForm').valid()) {
alert('if you see this then the form is valid.');
}
});
});
<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@1.10.0" data-semver="1.10.0" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/additional-methods.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>This doesn't work :(</h1>
<form id="detailsForm">
<div class="row guttered-bottom">
<div class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
First Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
Last Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
</div>
</div>
</div>
</div>
</div>
</form>
<br>
<button id="go">CLICK ME! </button>
</body>
</html>
Steps to reproduce: click the button and observe that the validation message comes up for the first field (first name). Enter a first name and click the button again. Notice that the form seems to validate even though both fields are required.
What am I doing wrong?
javascript jquery jquery-validate
marked as duplicate by Sparky
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 3:59
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
validating multiple textbox having same name with jquery validator validates only first input
4 answers
.valid() only validates first input with jQuery Validation plugin
1 answer
I've been struggling all day with a JQuery validate issue. Where it only validates the first field.
I've managed to reproduce it here:
$(document).ready(function() {
$('#go').click(function() {
console.log('go clicked');
if ($('#detailsForm').valid()) {
alert('if you see this then the form is valid.');
}
});
});
<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@1.10.0" data-semver="1.10.0" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/additional-methods.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>This doesn't work :(</h1>
<form id="detailsForm">
<div class="row guttered-bottom">
<div class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
First Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
Last Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
</div>
</div>
</div>
</div>
</div>
</form>
<br>
<button id="go">CLICK ME! </button>
</body>
</html>
Steps to reproduce: click the button and observe that the validation message comes up for the first field (first name). Enter a first name and click the button again. Notice that the form seems to validate even though both fields are required.
What am I doing wrong?
javascript jquery jquery-validate
marked as duplicate by Sparky
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 3:59
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I don't think this is quite a duplicate. It's similar yes but not a duplicate question.
– Prime By Design
Nov 20 '18 at 16:26
For this plugin to work, the form input elements need to have uniquename
attributes. If they are not unique or they are missing, the symptom is exactly what you describe. Whether validation is triggered manually by a button or programmatically by the.valid()
method is irrelevant.
– Sparky
Nov 21 '18 at 16:39
add a comment |
This question already has an answer here:
validating multiple textbox having same name with jquery validator validates only first input
4 answers
.valid() only validates first input with jQuery Validation plugin
1 answer
I've been struggling all day with a JQuery validate issue. Where it only validates the first field.
I've managed to reproduce it here:
$(document).ready(function() {
$('#go').click(function() {
console.log('go clicked');
if ($('#detailsForm').valid()) {
alert('if you see this then the form is valid.');
}
});
});
<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@1.10.0" data-semver="1.10.0" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/additional-methods.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>This doesn't work :(</h1>
<form id="detailsForm">
<div class="row guttered-bottom">
<div class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
First Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
Last Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
</div>
</div>
</div>
</div>
</div>
</form>
<br>
<button id="go">CLICK ME! </button>
</body>
</html>
Steps to reproduce: click the button and observe that the validation message comes up for the first field (first name). Enter a first name and click the button again. Notice that the form seems to validate even though both fields are required.
What am I doing wrong?
javascript jquery jquery-validate
This question already has an answer here:
validating multiple textbox having same name with jquery validator validates only first input
4 answers
.valid() only validates first input with jQuery Validation plugin
1 answer
I've been struggling all day with a JQuery validate issue. Where it only validates the first field.
I've managed to reproduce it here:
$(document).ready(function() {
$('#go').click(function() {
console.log('go clicked');
if ($('#detailsForm').valid()) {
alert('if you see this then the form is valid.');
}
});
});
<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@1.10.0" data-semver="1.10.0" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/additional-methods.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>This doesn't work :(</h1>
<form id="detailsForm">
<div class="row guttered-bottom">
<div class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
First Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
Last Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
</div>
</div>
</div>
</div>
</div>
</form>
<br>
<button id="go">CLICK ME! </button>
</body>
</html>
Steps to reproduce: click the button and observe that the validation message comes up for the first field (first name). Enter a first name and click the button again. Notice that the form seems to validate even though both fields are required.
What am I doing wrong?
This question already has an answer here:
validating multiple textbox having same name with jquery validator validates only first input
4 answers
.valid() only validates first input with jQuery Validation plugin
1 answer
$(document).ready(function() {
$('#go').click(function() {
console.log('go clicked');
if ($('#detailsForm').valid()) {
alert('if you see this then the form is valid.');
}
});
});
<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@1.10.0" data-semver="1.10.0" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/additional-methods.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>This doesn't work :(</h1>
<form id="detailsForm">
<div class="row guttered-bottom">
<div class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
First Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
Last Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
</div>
</div>
</div>
</div>
</div>
</form>
<br>
<button id="go">CLICK ME! </button>
</body>
</html>
$(document).ready(function() {
$('#go').click(function() {
console.log('go clicked');
if ($('#detailsForm').valid()) {
alert('if you see this then the form is valid.');
}
});
});
<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@1.10.0" data-semver="1.10.0" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/additional-methods.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>This doesn't work :(</h1>
<form id="detailsForm">
<div class="row guttered-bottom">
<div class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
First Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
Last Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
</div>
</div>
</div>
</div>
</div>
</form>
<br>
<button id="go">CLICK ME! </button>
</body>
</html>
javascript jquery jquery-validate
javascript jquery jquery-validate
edited Nov 20 '18 at 3:50
Sparky
82.2k20148238
82.2k20148238
asked Nov 19 '18 at 18:20
Prime By DesignPrime By Design
7161028
7161028
marked as duplicate by Sparky
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 3:59
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Sparky
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 3:59
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I don't think this is quite a duplicate. It's similar yes but not a duplicate question.
– Prime By Design
Nov 20 '18 at 16:26
For this plugin to work, the form input elements need to have uniquename
attributes. If they are not unique or they are missing, the symptom is exactly what you describe. Whether validation is triggered manually by a button or programmatically by the.valid()
method is irrelevant.
– Sparky
Nov 21 '18 at 16:39
add a comment |
I don't think this is quite a duplicate. It's similar yes but not a duplicate question.
– Prime By Design
Nov 20 '18 at 16:26
For this plugin to work, the form input elements need to have uniquename
attributes. If they are not unique or they are missing, the symptom is exactly what you describe. Whether validation is triggered manually by a button or programmatically by the.valid()
method is irrelevant.
– Sparky
Nov 21 '18 at 16:39
I don't think this is quite a duplicate. It's similar yes but not a duplicate question.
– Prime By Design
Nov 20 '18 at 16:26
I don't think this is quite a duplicate. It's similar yes but not a duplicate question.
– Prime By Design
Nov 20 '18 at 16:26
For this plugin to work, the form input elements need to have unique
name
attributes. If they are not unique or they are missing, the symptom is exactly what you describe. Whether validation is triggered manually by a button or programmatically by the .valid()
method is irrelevant.– Sparky
Nov 21 '18 at 16:39
For this plugin to work, the form input elements need to have unique
name
attributes. If they are not unique or they are missing, the symptom is exactly what you describe. Whether validation is triggered manually by a button or programmatically by the .valid()
method is irrelevant.– Sparky
Nov 21 '18 at 16:39
add a comment |
2 Answers
2
active
oldest
votes
jQuery Validate needs each input to have a name
attribute. Without this, it can't properly create the input objects it uses to store validation results.
Just add a unique name to each input and you should be good:
<input name="ReserveFirstName" id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
<input name="ReserveLastName" id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
Pat I wish I'd asked this earlier rather than struggling! thank you so much! I can't accept this answer for another 10 minutes.
– Prime By Design
Nov 19 '18 at 18:25
4
Similarly a form won't submit inputs with no name which is also why they get ignored for validation
– charlietfl
Nov 19 '18 at 18:25
@charlietfl good to know but shouldn't affect me in this case. Thanks though I upvoted you for that.
– Prime By Design
Nov 19 '18 at 18:26
Np @PrimeByDesign - the same thing got me years ago.
– Pat
Nov 19 '18 at 18:27
1
Validate also ignores fields that are disabled. Not applicable to your issue, but just an fyi.
– Taplar
Nov 19 '18 at 18:27
|
show 3 more comments
Valid returns a boolean value from the form but It has to be used before the onClick event.
var form = $( "#myform" );
form.validate();
$( "button" ).click(function() {
alert( "Valid: " + form.valid() );
});
You can try this yourself at the source: https://jqueryvalidation.org/valid/
That he should call a variable validating all the form before the onclick event?¿
– David Bros
Nov 19 '18 at 18:30
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
jQuery Validate needs each input to have a name
attribute. Without this, it can't properly create the input objects it uses to store validation results.
Just add a unique name to each input and you should be good:
<input name="ReserveFirstName" id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
<input name="ReserveLastName" id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
Pat I wish I'd asked this earlier rather than struggling! thank you so much! I can't accept this answer for another 10 minutes.
– Prime By Design
Nov 19 '18 at 18:25
4
Similarly a form won't submit inputs with no name which is also why they get ignored for validation
– charlietfl
Nov 19 '18 at 18:25
@charlietfl good to know but shouldn't affect me in this case. Thanks though I upvoted you for that.
– Prime By Design
Nov 19 '18 at 18:26
Np @PrimeByDesign - the same thing got me years ago.
– Pat
Nov 19 '18 at 18:27
1
Validate also ignores fields that are disabled. Not applicable to your issue, but just an fyi.
– Taplar
Nov 19 '18 at 18:27
|
show 3 more comments
jQuery Validate needs each input to have a name
attribute. Without this, it can't properly create the input objects it uses to store validation results.
Just add a unique name to each input and you should be good:
<input name="ReserveFirstName" id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
<input name="ReserveLastName" id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
Pat I wish I'd asked this earlier rather than struggling! thank you so much! I can't accept this answer for another 10 minutes.
– Prime By Design
Nov 19 '18 at 18:25
4
Similarly a form won't submit inputs with no name which is also why they get ignored for validation
– charlietfl
Nov 19 '18 at 18:25
@charlietfl good to know but shouldn't affect me in this case. Thanks though I upvoted you for that.
– Prime By Design
Nov 19 '18 at 18:26
Np @PrimeByDesign - the same thing got me years ago.
– Pat
Nov 19 '18 at 18:27
1
Validate also ignores fields that are disabled. Not applicable to your issue, but just an fyi.
– Taplar
Nov 19 '18 at 18:27
|
show 3 more comments
jQuery Validate needs each input to have a name
attribute. Without this, it can't properly create the input objects it uses to store validation results.
Just add a unique name to each input and you should be good:
<input name="ReserveFirstName" id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
<input name="ReserveLastName" id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
jQuery Validate needs each input to have a name
attribute. Without this, it can't properly create the input objects it uses to store validation results.
Just add a unique name to each input and you should be good:
<input name="ReserveFirstName" id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your first name" required="true" />
<input name="ReserveLastName" id="ReserveLastName" type="text" class="input-large input-wide" placeholder="Enter your last name" required="true" />
edited Nov 19 '18 at 18:26
answered Nov 19 '18 at 18:23
PatPat
21.5k55262
21.5k55262
Pat I wish I'd asked this earlier rather than struggling! thank you so much! I can't accept this answer for another 10 minutes.
– Prime By Design
Nov 19 '18 at 18:25
4
Similarly a form won't submit inputs with no name which is also why they get ignored for validation
– charlietfl
Nov 19 '18 at 18:25
@charlietfl good to know but shouldn't affect me in this case. Thanks though I upvoted you for that.
– Prime By Design
Nov 19 '18 at 18:26
Np @PrimeByDesign - the same thing got me years ago.
– Pat
Nov 19 '18 at 18:27
1
Validate also ignores fields that are disabled. Not applicable to your issue, but just an fyi.
– Taplar
Nov 19 '18 at 18:27
|
show 3 more comments
Pat I wish I'd asked this earlier rather than struggling! thank you so much! I can't accept this answer for another 10 minutes.
– Prime By Design
Nov 19 '18 at 18:25
4
Similarly a form won't submit inputs with no name which is also why they get ignored for validation
– charlietfl
Nov 19 '18 at 18:25
@charlietfl good to know but shouldn't affect me in this case. Thanks though I upvoted you for that.
– Prime By Design
Nov 19 '18 at 18:26
Np @PrimeByDesign - the same thing got me years ago.
– Pat
Nov 19 '18 at 18:27
1
Validate also ignores fields that are disabled. Not applicable to your issue, but just an fyi.
– Taplar
Nov 19 '18 at 18:27
Pat I wish I'd asked this earlier rather than struggling! thank you so much! I can't accept this answer for another 10 minutes.
– Prime By Design
Nov 19 '18 at 18:25
Pat I wish I'd asked this earlier rather than struggling! thank you so much! I can't accept this answer for another 10 minutes.
– Prime By Design
Nov 19 '18 at 18:25
4
4
Similarly a form won't submit inputs with no name which is also why they get ignored for validation
– charlietfl
Nov 19 '18 at 18:25
Similarly a form won't submit inputs with no name which is also why they get ignored for validation
– charlietfl
Nov 19 '18 at 18:25
@charlietfl good to know but shouldn't affect me in this case. Thanks though I upvoted you for that.
– Prime By Design
Nov 19 '18 at 18:26
@charlietfl good to know but shouldn't affect me in this case. Thanks though I upvoted you for that.
– Prime By Design
Nov 19 '18 at 18:26
Np @PrimeByDesign - the same thing got me years ago.
– Pat
Nov 19 '18 at 18:27
Np @PrimeByDesign - the same thing got me years ago.
– Pat
Nov 19 '18 at 18:27
1
1
Validate also ignores fields that are disabled. Not applicable to your issue, but just an fyi.
– Taplar
Nov 19 '18 at 18:27
Validate also ignores fields that are disabled. Not applicable to your issue, but just an fyi.
– Taplar
Nov 19 '18 at 18:27
|
show 3 more comments
Valid returns a boolean value from the form but It has to be used before the onClick event.
var form = $( "#myform" );
form.validate();
$( "button" ).click(function() {
alert( "Valid: " + form.valid() );
});
You can try this yourself at the source: https://jqueryvalidation.org/valid/
That he should call a variable validating all the form before the onclick event?¿
– David Bros
Nov 19 '18 at 18:30
add a comment |
Valid returns a boolean value from the form but It has to be used before the onClick event.
var form = $( "#myform" );
form.validate();
$( "button" ).click(function() {
alert( "Valid: " + form.valid() );
});
You can try this yourself at the source: https://jqueryvalidation.org/valid/
That he should call a variable validating all the form before the onclick event?¿
– David Bros
Nov 19 '18 at 18:30
add a comment |
Valid returns a boolean value from the form but It has to be used before the onClick event.
var form = $( "#myform" );
form.validate();
$( "button" ).click(function() {
alert( "Valid: " + form.valid() );
});
You can try this yourself at the source: https://jqueryvalidation.org/valid/
Valid returns a boolean value from the form but It has to be used before the onClick event.
var form = $( "#myform" );
form.validate();
$( "button" ).click(function() {
alert( "Valid: " + form.valid() );
});
You can try this yourself at the source: https://jqueryvalidation.org/valid/
answered Nov 19 '18 at 18:27
David BrosDavid Bros
2016
2016
That he should call a variable validating all the form before the onclick event?¿
– David Bros
Nov 19 '18 at 18:30
add a comment |
That he should call a variable validating all the form before the onclick event?¿
– David Bros
Nov 19 '18 at 18:30
That he should call a variable validating all the form before the onclick event?¿
– David Bros
Nov 19 '18 at 18:30
That he should call a variable validating all the form before the onclick event?¿
– David Bros
Nov 19 '18 at 18:30
add a comment |
I don't think this is quite a duplicate. It's similar yes but not a duplicate question.
– Prime By Design
Nov 20 '18 at 16:26
For this plugin to work, the form input elements need to have unique
name
attributes. If they are not unique or they are missing, the symptom is exactly what you describe. Whether validation is triggered manually by a button or programmatically by the.valid()
method is irrelevant.– Sparky
Nov 21 '18 at 16:39