I am using a jquery ui dialog as a prompt. The "prompt" has to buttons, "Ok" and "Cancel". The problem here is, it extracts the input fields value in the dialog when .dialog("close") is triggered and my only validation is that the length of the input field has to be more than 0 chars. This means that even when you type something and press cancel the text from the prompt will be submittet. My thought was to find out what button was pressed... Anyone know a solution to this?
My current event code:
$("#addBusinessarea").click(function(){
createPrompt("Add new business area", "Business area name:");
$( "#prompt" ).bind( "dialogclose", function(event, ui) {
if($("#promptValue").val().length > 0){
// Add business area
}
});
});