Skip to content

Instantly share code, notes, and snippets.

@wataru218
Created June 27, 2013 10:43
Show Gist options
  • Save wataru218/5875541 to your computer and use it in GitHub Desktop.
Save wataru218/5875541 to your computer and use it in GitHub Desktop.
A CodePen by iw3. jQuery UI Dialog + validate
<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>
$(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