Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 必填字段在texarea上不起作用_Javascript_Php_Jquery_Html - Fatal编程技术网

Javascript 必填字段在texarea上不起作用

Javascript 必填字段在texarea上不起作用,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我有一个表单,它有一些字段,为了填充所有字段并传递表单和减少垃圾邮件,我编写了一些JS代码,使一些字段成为必填字段,并禁用提交按钮,直到填充所有字段,JS对输入类型=文本非常有效,但对texarea不起作用 JS代码 <script type="text/javascript"> $(document).ready(function() { $(function() { $('#sbtbtn').attr('disabled', 'disabled'); });

我有一个表单,它有一些字段,为了填充所有字段并传递表单和减少垃圾邮件,我编写了一些JS代码,使一些字段成为必填字段,并禁用提交按钮,直到填充所有字段,JS对输入类型=文本非常有效,但对texarea不起作用

JS代码

 <script type="text/javascript">
     $(document).ready(function() {

$(function() {
    $('#sbtbtn').attr('disabled', 'disabled');
});

$('input[type=text],input[type=textarea],input[type=password]').keyup(function() {

    if ($('#target1').val() !='' &&
    $('#target2').val() != '' &&
    $('#target3').val() != '' &&
    $('#target4').val() != '' &&
    $('#target5').val() != '' &&
    $('#target6').val() != '' &&
    $('#target7').val() != '' &&
    $('#target8').val() != '' &&
    $('#target9').val() != '' &&
    $('#target10').val() != '' &&
    $('#target11').val() != '' &&
    $('#target12').val() != '' &&
    $('#target13').val() != '' &&
    $('#target14').val() != '' &&
    $('#target15').val() != '' &&
    //this is for textarea id
    $('#editor1').val() != '') {

        $('#sbtbtn').removeAttr('disabled');
    } else {
        $('#sbtbtn').attr('disabled', 'disabled');
    }
});
    });</script>
<form action="insert.php" method="post" class="ara-form" name="theform">
                <header>Enter Job Details</header>

                <fieldset>                  
                    <div class="row">
                        <section class="col col-6">
                            <label class="input">
                            <i class="icon-append icon-company"></i>
                                <input type="text" id="target1" placeholder="Job Title" name="positiontitle">
                                <div class="note note-error">This is a required field.</div>
                                <span class="error"></span>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target2" placeholder="Organization / Company Name" name="companyname">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                    </div>

                    <div class="row">
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target3" placeholder="Location" name="location" >
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target4" placeholder="Job Category  e.g. IT" name="jobcategory">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text"  id="target5" placeholder="Employment Type  e.g. Full Time" name="employmenttype">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target6" placeholder="Salary  e.g. 5000$" name="salary">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target7" placeholder="Duration  e.g. Permanent" name="duration">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i> 
                                <input type="text" id="target8" placeholder="Timing  e.g. 8 AM - 4 PM" name="timing">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target9" placeholder="Nationality" name="nationality">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target10" placeholder="Number of Vacancy  e.g. 2 Post(s)" name="numberofvacancy">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target11" placeholder="Experience  e.g. 3 Years" name="experience">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Closing Date" id="datepicker" name="closingdate">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target13" placeholder="Gender" name="gender">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target14" placeholder="Education  e.g. Bachelor" name="education">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                     </div>             
                </fieldset>

                <fieldset>  

                    <section>
                        <label class="textarea">

                            Tell us about your company background
                            <textarea id="editor1" rows="10" cols="80"  name="background" placeholder="Tell us about your company background"></textarea>
                        </label>
                    </section>                  

                </fieldset>
                <footer>
                    <p>Fill all fields to activate the submit button.</br>
                    Thanks</p><i class="fa fa-check" style="float: right; position: relative; right: 22px; color: white; z-index: 1; padding-top: 23px;"></i><input 
                    class="button" type="submit" value="Submit"

                    id="sbtbtn" />

                   <div style="float: right; padding-right: 10px;"><?php
                   include "../module/back.php";
                   ?></div>
                    </footer>
            </form>

$(文档).ready(函数(){
$(函数(){
$('sbtbtn').attr('disabled','disabled');
});
$('input[type=text]、input[type=textarea]、input[type=password]).keyup(函数(){
如果($('#target1').val()!=''&&
$('#target2').val()!=''&&
$('#target3').val()!=''&&
$('#target4').val()!=''&&
$('#target5').val()!=''&&
$('#target6').val()!=''&&
$('#target7').val()!=''&&
$('#target8').val()!=''&&
$('#target9').val()!=''&&
$('#target10').val()!=''&&
$('#target11').val()!=''&&
$('#target12').val()!=''&&
$('#target13').val()!=''&&
$('#target14').val()!=''&&
$('#target15').val()!=''&&
//这是用于文本区域id的
$('#editor1').val()!=''){
$('sbtbtn').removeAttr('disabled');
}否则{
$('sbtbtn').attr('disabled','disabled');
}
});
});
HTML代码

 <script type="text/javascript">
     $(document).ready(function() {

$(function() {
    $('#sbtbtn').attr('disabled', 'disabled');
});

$('input[type=text],input[type=textarea],input[type=password]').keyup(function() {

    if ($('#target1').val() !='' &&
    $('#target2').val() != '' &&
    $('#target3').val() != '' &&
    $('#target4').val() != '' &&
    $('#target5').val() != '' &&
    $('#target6').val() != '' &&
    $('#target7').val() != '' &&
    $('#target8').val() != '' &&
    $('#target9').val() != '' &&
    $('#target10').val() != '' &&
    $('#target11').val() != '' &&
    $('#target12').val() != '' &&
    $('#target13').val() != '' &&
    $('#target14').val() != '' &&
    $('#target15').val() != '' &&
    //this is for textarea id
    $('#editor1').val() != '') {

        $('#sbtbtn').removeAttr('disabled');
    } else {
        $('#sbtbtn').attr('disabled', 'disabled');
    }
});
    });</script>
<form action="insert.php" method="post" class="ara-form" name="theform">
                <header>Enter Job Details</header>

                <fieldset>                  
                    <div class="row">
                        <section class="col col-6">
                            <label class="input">
                            <i class="icon-append icon-company"></i>
                                <input type="text" id="target1" placeholder="Job Title" name="positiontitle">
                                <div class="note note-error">This is a required field.</div>
                                <span class="error"></span>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target2" placeholder="Organization / Company Name" name="companyname">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                    </div>

                    <div class="row">
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target3" placeholder="Location" name="location" >
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target4" placeholder="Job Category  e.g. IT" name="jobcategory">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text"  id="target5" placeholder="Employment Type  e.g. Full Time" name="employmenttype">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target6" placeholder="Salary  e.g. 5000$" name="salary">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target7" placeholder="Duration  e.g. Permanent" name="duration">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i> 
                                <input type="text" id="target8" placeholder="Timing  e.g. 8 AM - 4 PM" name="timing">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target9" placeholder="Nationality" name="nationality">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target10" placeholder="Number of Vacancy  e.g. 2 Post(s)" name="numberofvacancy">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target11" placeholder="Experience  e.g. 3 Years" name="experience">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Closing Date" id="datepicker" name="closingdate">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target13" placeholder="Gender" name="gender">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" id="target14" placeholder="Education  e.g. Bachelor" name="education">
                                <div class="note note-error">This is a required field.</div>
                            </label>
                        </section>
                     </div>             
                </fieldset>

                <fieldset>  

                    <section>
                        <label class="textarea">

                            Tell us about your company background
                            <textarea id="editor1" rows="10" cols="80"  name="background" placeholder="Tell us about your company background"></textarea>
                        </label>
                    </section>                  

                </fieldset>
                <footer>
                    <p>Fill all fields to activate the submit button.</br>
                    Thanks</p><i class="fa fa-check" style="float: right; position: relative; right: 22px; color: white; z-index: 1; padding-top: 23px;"></i><input 
                    class="button" type="submit" value="Submit"

                    id="sbtbtn" />

                   <div style="float: right; padding-right: 10px;"><?php
                   include "../module/back.php";
                   ?></div>
                    </footer>
            </form>

输入作业详细信息
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
这是必填字段。
告诉我们你的公司背景
填写所有字段以激活提交按钮
谢谢


任何解决方案都将不胜感激。

您指的是类似于输入[type=textarea]的textarea。这是错误的

像这样更新脚本

<script type="text/javascript">
 $(document).ready(function() {

$(function() {
$('#sbtbtn').attr('disabled', 'disabled');
});

$('input[type=text],textarea,input[type=password]').keyup(function() {

if ($('#target1').val() !='' &&
$('#target2').val() != '' &&
$('#target3').val() != '' &&
$('#target4').val() != '' &&
$('#target5').val() != '' &&
$('#target6').val() != '' &&
$('#target7').val() != '' &&
$('#target8').val() != '' &&
$('#target9').val() != '' &&
$('#target10').val() != '' &&
$('#target11').val() != '' &&
$('#target12').val() != '' &&
$('#target13').val() != '' &&
$('#target14').val() != '' &&
$('#target15').val() != '' &&
//this is for textarea id
$('#editor1').val() != '') {

    $('#sbtbtn').removeAttr('disabled');
} else {
    $('#sbtbtn').attr('disabled', 'disabled');
}
});
});</script>

$(文档).ready(函数(){
$(函数(){
$('sbtbtn').attr('disabled','disabled');
});
$('input[type=text],textarea,input[type=password]).keyup(函数(){
如果($('#target1').val()!=''&&
$('#target2').val()!=''&&
$('#target3').val()!=''&&
$('#target4').val()!=''&&
$('#target5').val()!=''&&
$('#target6').val()!=''&&
$('#target7').val()!=''&&
$('#target8').val()!=''&&
$('#target9').val()!=''&&
$('#target10').val()!=''&&
$('#target11').val()!=''&&
$('#target12').val()!=''&&
$('#target13').val()!=''&&
$('#target14').val()!=''&&
$('#target15').val()!=''&&
//这是用于文本区域id的
$('#editor1').val(