检查是否设置了输入类型按钮? [英] Check if input type button is set?

查看:95
本文介绍了检查是否设置了输入类型按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我有一个带输入类型按钮的表单:



Hi. I have a form with input type button:

<form method="post" action="index.php" id="addForm" name="addForm" enctype="multipart/form-data">
      ...
      <input type="button" class="btns" value="Add" id="submitAdd" name="submitAdd"/>
</form>





这是我用于表单验证和提交表单的jQuery代码:





This is my jQuery code that I use for form validation and submitting form:

$('#submitAdd').click(function (){
	// validating input and if everything is right submitting the form	
	$('#addForm').submit();
});





现在,如果我想检查按钮submitAdd是否为空,则没有任何反应:



Now if I want to check if button submitAdd is empty nothing happens:

if(!empty($_POST('submitAdd'))) //this is always false; if I put true script is normally done 





我尝试过:



我不能把输入类型提交而不是按钮,因为表格会自动提交。我该如何避免这种情况?请帮助。



What I have tried:

I can't put input type submit instead button because form is then automatically submitted. How can I avoid this situation? Please help.

推荐答案

' #submitAdd').click( function (){
// 验证输入,如果一切正确,提交表单
('#submitAdd').click(function (){ // validating input and if everything is right submitting the form


' #addForm')。submit();
});
('#addForm').submit(); });





现在如果我想检查按钮submitAdd是否为空则没有任何反应:



Now if I want to check if button submitAdd is empty nothing happens:

if(!empty(


_POST(' submitAdd'))) // 这总是假的;如果我把真正的脚本通常完成
_POST('submitAdd'))) //this is always false; if I put true script is normally done





我尝试过:



我不能把输入类型提交而不是按钮,因为表格会自动提交。我该如何避免这种情况?请帮忙。



What I have tried:

I can't put input type submit instead button because form is then automatically submitted. How can I avoid this situation? Please help.


这篇关于检查是否设置了输入类型按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆