简体   繁体   中英

Jquery Dialogue isn't working

I'm creating a custom alert by using jquery dialogue and currently on click submit (with id=submit) it checks to see if the value of id choose_client = "" and if so, prompt dialogue box and not process form. What its doing instead is processing the form instead AND not even showing the dialogue. Any ideas why? Here is my code:

$('#submit').click(function(){
        if($('#choose_client').val() == ''){
            $("<div title='Invoice Error'>Please Choose A Client</div>").dialog();
            event.preventDefault();
        }
    }); 

html:

<form method="post" action="new_invoice.php">
Client: <select id="choose_client" name="client">
<option name="client_none" value="">Choose A Client</option>
</select>
<input type="submit" id="submit" name="submit" value="Submit" class="step" disabled>
</form><br />

In order for event.preventDefault(); to work, you need to pass event as an argument:

$('#submit').click(function(event){

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM