简体   繁体   English

jQuery对话不起作用

[英]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. 我正在通过使用jquery对话框创建自定义警报,当前单击“提交”(id = submit)时,它会检查ID是否为select_client =“”,如果是,则提示对话框而不处理表单。 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: 的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(); 为了event.preventDefault(); to work, you need to pass event as an argument: 要工作,您需要将event作为参数传递:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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