I'm trying to call a function inside a form validation function, but it's not working. The function confirm_submit should be called if valid is true.
$(document).ready(function() {
$("#dialog").dialog({
autoOpen: false,
buttons : {
"Confirm" : function() {
$('#form').submit();
},
"Cancel" : function() {
$(this).dialog("close");
}
}
});
function confirm_submit(){
$("#dialog").dialog('open');
}
});
function validate(){
valid = true;
if ( document.form.number.value == ""){
alert ( "You need to complete the Number field." );
valid = false;
return valid;
}
if(valid){
confirm_submit();
}
}