JSFiddle - React, Tailwind, and code Playground
HTML
<form role="form" action="dash.html" method="post" class="validate">
<div class="form-group">
<label class="control-label" for="login_id">Login id:</label>
<input type="text" class="form-control required" id="login_id">
</div>
<div class="form-group">
<label class="control-label" for="password">Password:</label>
<input type="password" class="form-control required" id="password">
<div class="forgot">
<a href="#">
Forgot your password?
</a>
</div>
</div>
<div class="form-group">
<p class="note">
Please enter the security code below.
<br>
Note: this code is case sensitive
</p>
</div>
<div class="form-group">
<div class="captcha">
<img src="style/css/images/captcha-example.png">
</div>
<label class="control-label" for="captcha">Security code:</label>
<input type="text" class="form-control required" id="captcha">
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger">Log in</button>
</div>
</form>
JavaScript
/**
* jQuery Validation Plugin 1.9.0
*
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
* Copyright (c) 2006 - 2011 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($) {
$.extend($.fn, {
// http://docs.jquery.com/Plugins/Validation/validate
validate: function( options ) {
// if nothing is selected, return nothing; can't chain anyway
if (!this.length) {
options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
return;
}
// check if a validator for this form was already created
var validator = $.data(this[0], 'validator');
if ( validator ) {
return validator;
}
// Add novalidate tag if HTML5.
this.attr('novalidate', 'novalidate');
validator = new $.validator( options, this[0] );
$.data(this[0], 'validator', validator);
if ( validator.settings.onsubmit ) {
var inputsAndButtons = this.find("input, button");
// allow suppresing validation by adding a cancel class to the submit button
inputsAndButtons.filter(".cancel").click(function () {
validator.cancelSubmit = true;
});
// when a submitHandler is used, capture the submitting button
if (validator.settings.submitHandler) {
inputsAndButtons.filter(":submit").click(function () {
validator.submitButton = this;
});
}
// validate the form on submit
this.submit( function( event ) {
if ( validator.settings.debug )
// prevent form submit to be able to see console output
event.preventDefault();
function handle() {
if ( validator.settings.submitHandler ) {
if (validator.submitButton) {
// insert a hidden input as a replacement for the missing submit button
var hidden = $("<input type='hidden'/>").attr("name",...