I have a simple jQuery dialog box that has an html input inside it. There are two buttons Save/Cancel on the dialog box. When the user hits Save, I validate if he has provided any input in the input box. If he hasn't, I report the error on a new line in the dialog box and wait for him to provide input. But when he hits Save again, nothing happens. How can I re-bind the Save button once it has been used? Thanks!
var message = "Please provide Phone number."
var phoneNum = "<input type='text' id='phoneNum' name='phoneNum'/> ";
var dialogHtml = "<div id='confirmPhoneNumber'>" + message + phoneNum + "<div id='dialogError' style='display:none'>Phone number field cannot be empty</div>" + "</div>";
$(this).append(dialogHtml);
$("#confirmPhoneNumber").css("font-size", "70%");
$("#confirmPhoneNumber").dialog({
resizable : false,
modal : true,
title : 'Save Phone',
buttons : {
'Save' : function () {
// Phone number must be provided
if ($("#phoneNum").val().trim().length == 0) {
$("#dialogError").show();
} else {
// Make AJAX call
}
},
'Cancel' : function () {
$(this).dialog('close');
}
}
});