Created
June 27, 2013 10:43
-
-
Save wataru218/5875541 to your computer and use it in GitHub Desktop.
A CodePen by iw3. jQuery UI Dialog + validate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input id="openButton" type="button" value="Open" /> | |
<div id="dialog"> | |
<form id="form"> | |
<input type="text" id="name" name="name" /> | |
<input type="text" id="pinCode" name="pinCode" /> | |
</form> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
$('#dialog').dialog({ | |
autoOpen: false, | |
buttons: { | |
'Send': function() { | |
console.debug('valid():' + $('#form').valid()); | |
if ($('#form').valid()) { | |
alert('Success'); | |
$('#dialog').dialog('close'); | |
} | |
} | |
} | |
}); | |
$('#openButton').on('click', function() { | |
$('#dialog').dialog('open'); | |
}); | |
$('#form').validate({ | |
rules: { | |
pinCode: { | |
required: true, | |
digits: true, | |
maxlength: 9, | |
min: 1 | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment