Compare two textboxes in JQuery
Compare two textboxes in jquery, compare two input fields jquery, compare two inputs javascript
by Anjan Kant
HTML
<form action="#" method="post" name="form_name" id="form_id">
<input type="text" id="txt1" name="txt1" />
<input type="text" id="txt2" name="txt2"/>
<input type="submit" value="Submit">
</form>
JavaScript
$("form").submit(function() {
var _txt1 = $('#txt1').val();
var _txt2 = $('#txt2').val();
if (_txt1 == _txt2)
{
alert('Matching!');
return true;
}
else
{
alert('Not matching!');
return false;
}
});