Php 仅在字段满足时发送表单(获取)数据(非验证)
我有一张表格,就是这张Php 仅在字段满足时发送表单(获取)数据(非验证),php,javascript,html,Php,Javascript,Html,我有一张表格,就是这张 <form method="get" action="<?php bloginfo('url'); ?>"> <input name="date-beginning" type="text" class="datepicker" /> <input name="date-end" type="text" class="datepicker" /> <input name="s" type="text"
<form method="get" action="<?php bloginfo('url'); ?>">
<input name="date-beginning" type="text" class="datepicker" />
<input name="date-end" type="text" class="datepicker" />
<input name="s" type="text" />
<input type="submit" value="Ok" class="botao-pequeno botao-pequeno-input" />
</form>
karaxuna的anwser工程。我只是将它改编成jQuery,如果有人感兴趣,这就是代码
$("#the-form").submit(function() {
if($('#the-field').val() === ''){
$('#the-field').attr('disabled',true);
}
if($('#the-other-field').val() === ''){
$('#the-other-field').attr('disabled',true);
}
});
不,这并没有简单的任务,但请注意:这仍然是验证。只是您没有阻止表单提交,而是删除表单项,然后提交。
$("#the-form").submit(function() {
if($('#the-field').val() === ''){
$('#the-field').attr('disabled',true);
}
if($('#the-other-field').val() === ''){
$('#the-other-field').attr('disabled',true);
}
});