Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.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或jquery中的动态字段验证_Javascript_Jquery_Html - Fatal编程技术网

javascript或jquery中的动态字段验证

javascript或jquery中的动态字段验证,javascript,jquery,html,Javascript,Jquery,Html,这是我的Html表单,我用它创建表单和动态字段 <div style="margin:10px 0;color:#574F44;margin-left:160px;"> <form name="frmsignup3" method="post" action="new_user2.php" style="margin-top:0px; line-height:60px;" enctype="multipart/form-data" onsubmit="return va

这是我的Html表单,我用它创建表单和动态字段

<div style="margin:10px 0;color:#574F44;margin-left:160px;">
    <form name="frmsignup3" method="post" action="new_user2.php" style="margin-top:0px; line-height:60px;" enctype="multipart/form-data" onsubmit="return validateForm2()" >
        <input type="hidden" name="user_name" value="<?php echo $_POST['user_name']?>" />
        <input type="hidden" name="user_email" value="<?php echo $_POST['user_email']?>" />
        <input type="hidden" name="user_pass" value="<?php echo $_POST['user_pass']?>" />
        <input type="hidden" name="user_gen" value="<?php echo $_POST['user_gen']?>" />
        <input type="hidden" name="user_dob_m" value="<?php echo $_POST['user_dob_m']?>" />
        <input type="hidden" name="user_dob_d" value="<?php echo $_POST['user_dob_d']?>" />
        <input type="hidden" name="user_dob_y" value="<?php echo $_POST['user_dob_y']?>" />
        <input type="hidden" name="user_ili" value="<?php echo $_POST['user_ili']?>" />
        <input type="hidden" name="user_pc" value="<?php echo $_POST['user_pc']?>" />
        <input type="hidden" name="user_prof" value="<?php echo $_POST['user_prof']?>" />

        <label id="l" style="width:80px;">Specialities:</label>
        <input id="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user[]"/>
        <!---------Dyanmic Fields  for specialities---------->
        <div id="add_user" style="display: none;"><label id="l" style="width:80px;">&nbsp;</label><input id="l"  class="l"type="text" size="37" style="width:auto;" name="user[]" value="" /></div>
        <input type="button" id="add_user()" onclick="add_user('add_user')" value="Add More!" /><br>
        <br class="clear"/>
        <!---------Dyanmic Fields ---------->

        <label id="l" style="width:120px;">Employment History:</label>
        <br class="clear"/>
        <label id="l" style="width:80px;">Role:</label>
        <input id="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user_role[]"/>
        <br class="clear"/>
        <label id="l" style="width:80px;">Company:</label>
        <input id="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user_com[]"/>
        <br class="clear"/>
        <label id="l" style="width:80px;">From:</label>
        <input id="datepicker"  class="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user_from[]"/>
        <br class="clear"/>
        <label id="l" style="width:80px;">To:</label>
        <input id="datepicker1" class="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user_to[]"/>
        <br class="clear"/>

        <!---------Dyanmic Fields for employment history---------->
        <div id="add_user1" style="display: none;" >
        <label id="l" style="width:80px;">Role:</label><input id="l" type="text" size="37" style="width:auto;" name="user_role[]" value="" /><br class="clear"/>
        <label id="l" style="width:80px;">Company:</label><input id="l" type="text" size="37" style="width:auto;" name="user_com[]" value="" /><br class="clear"/>
        <label id="l" style="width:80px;">From:</label><input class="datepicker"  type="text" size="37" onblur="" value="" style=":Arial;font-weight:normal;font-size:11px;color:#7c7b77;outline: none;border: 1px solid #c7c7c7;margin:3px 5px;padding:8px 0;padding-left:5px;-moz-box-shadow: 0 0 5px #c7c7c7;-webkit-box-shadow: 0 0 5px #c7c7c7;box-shadow: 0 0 5px #c7c7c7;float:left;border-radius: 5px;" name="user_from[]" /><br class="clear"/>
        <label id="l" style="width:80px;">To:</label><input class="datepicker" type="text" size="37" onblur="" value="" style=":Arial;font-weight:normal;font-size:11px;color:#7c7b77;outline: none;border: 1px solid #c7c7c7;margin:3px 5px;padding:8px 0;padding-left:5px;-moz-box-shadow: 0 0 5px #c7c7c7;-webkit-box-shadow: 0 0 5px #c7c7c7;box-shadow: 0 0 5px #c7c7c7;float:left;border-radius: 5px;" name="user_to[]"/><br class="clear"/></div>
        <input type="button" id="add_user1()" onclick="add_user1('add_user1')" name="btn" value="Add More!" /><br>
        <br class="clear"/>
        <!---------Dyanmic Fields ---------->

        <label id="l" style="width:80px;">Qualification:</label>
        <br class="clear"/>
        <label id="l" style="width:80px;">Degree:</label>
        <input id="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user_quli[]"/>
        <br class="clear"/>
        <label id="l" style="width:80px;">Institute:</label>
        <input id="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user_ins[]"/>
        <br class="clear"/>
        <label id="l" style="width:80px;">From:</label>
        <input id="datepicker2" class="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user_qfrom[]"/>
        <br class="clear"/>
        <label id="l" style="width:80px;">To:</label>
        <input id="datepicker3" class="l" type="text" size="37" onblur="" value="" style="width:auto;" name="user_qto[]"/>
        <br class="clear"/>

        <!---------Dyanmic Fields for education---------->
        <div id="add_user2" style="display: none;">
        <label id="l" style="width:80px;">Degree:</label><input id="l" type="text" size="37" style="width:auto;" name="user_quli[]" value="" /><br class="clear"/>
        <label id="l" style="width:80px;">Institute:</label><input id="l" type="text" size="37" style="width:auto;" name="user_ins[]" value="" /><br class="clear"/>
        <label id="l" style="width:80px;">From:</label><input  class="datepicker"  type="text" size="37" onblur="" value="" style=":Arial;font-weight:normal;font-size:11px;color:#7c7b77;outline: none;border: 1px solid #c7c7c7;margin:3px 5px;padding:8px 0;padding-left:5px;-moz-box-shadow: 0 0 5px #c7c7c7;-webkit-box-shadow: 0 0 5px #c7c7c7;box-shadow: 0 0 5px #c7c7c7;float:left;border-radius: 5px;" name="user_qfrom[]" /><br class="clear"/>
        <label id="l" style="width:80px;">To:</label><input class="datepicker"  type="text" size="37" onblur="" value="" style=":Arial;font-weight:normal;font-size:11px;color:#7c7b77;outline: none;border: 1px solid #c7c7c7;margin:3px 5px;padding:8px 0;padding-left:5px;-moz-box-shadow: 0 0 5px #c7c7c7;-webkit-box-shadow: 0 0 5px #c7c7c7;box-shadow: 0 0 5px #c7c7c7;float:left;border-radius: 5px;" name="user_qto[]"/><br class="clear"/></div>
        <input type="button" id="add_user2()" onclick="add_user2('add_user2')" value="Add More!" /><br>
        <br class="clear"/> 
        <!---------Dyanmic Fields ---------->
        <!--Error Div-->
        <div  id="errorcv" style="display: none"> 

        </div>  
        <!--Error Div-->               
        <label id="l" style="width:80px;">Upload CV:</label>
        <input id="l" type="file" size="37"  style="width:auto;" name="user_cv" onblur="return checkcv('user_cv')" accept="application/msword"/>
        <br class="clear"/>
        <!--Error Div-->
        <div  id="errorimg" style="display: none"> 
        </div>  
        <!--Error Div-->
        <label id="l" style="width:80px;">Upload Image:</label>
        <input id="l" type="file" size="37"  style="width:auto;" name="user_img" onblur="return checkPhoto('user_img')" accept="image/*"/>
        <br class="clear"/>
        <label id="l" style="width:80px; margin-left:90px; margin-right:15px;"><a href="" >Skip this step</a></label>
        <input type="image" src="<?php echo DIR_PATH?>images/btn_next.gif" alt=""/>
        <br class="clear"/>
    </form>


我假设您有不同类型的字段。所以,当您添加新字段时,会向每个不同的类型添加相同的类。然后,您可以在向chekc发送所有类型的邮件之前轻松设置验证程序函数,如下所示:

function your_validator() {
var passed = true;
$('.Specialities').each(function(){
 var current = $.trim($(this).val());
 if (your_false_condition) passed = false;//chekc specialiti value if its not ok
});

if (passed == false) {
alert('error');
return false;
}
return true;
}

说真的,伙计-一个div可以解释的东西并不需要你的全部源代码。请减少您发布代码的大小,以便我们能够关注相关内容。现在,你所说的“验证”是什么意思?@SudiptaChatterjee Chatterjee我想让你知道动态创建的字段不能空白提交!!!!
function your_validator() {
var passed = true;
$('.Specialities').each(function(){
 var current = $.trim($(this).val());
 if (your_false_condition) passed = false;//chekc specialiti value if its not ok
});

if (passed == false) {
alert('error');
return false;
}
return true;
}