JSFiddle - React, Tailwind, and code Playground
by joplomacedo
HTML
<form>
<input class="pw1" type="text" />
<div class="pw2row">
<input class="pw2" type="text" />
</div>
</form>
JavaScript
function Forminate( $form ) {
this.$form = $form;
this.$pw1 = $form.find('.pw1');
this.$pw2 = $form.find('.pw2');
this.$pws = this.$pw1.add(this.$pw2);
this.$pw2row = this.$pw2.closest('.pw2row');
this.$saveBtn = $form.find('.saveBtn');
this.$inputs = $form.find('inputs');
this.$pw1.on('change', $pw1_change.bind(this));
this.$pw2.on('focus', $pw2_focus.bind(this));
}
$pw1_change = function () {
if ( this.$pw1.val() === this.$pw2.val() ) {
alert('woot');
}
};
$pw2_focus = function () {
if ( this.$pw2.val() === "") {
alert('wiiyei');
}
};
(new Forminate( $('form') ));