dsc862009 2014-12-28 09:24
浏览 52

动态php echo字段的Jquery验证

Hi i am developing a multi page form in which you have to enter the number of people in the first step and then in the next step you enter the information for the same number of people. Now i am posting the data to step 2 and fetching the data via sessions.i am using this code inside form body .

 <?php 
 $i=0; 
 for($i=1;$i<=$_POST['number'];$i++) 
   echo $message='
                <div class="section colm colm4">
                <label for="firstname" class="field prepend-icon">
               <input type="text" name="firstname['.$i.']" id="firstname" class="gui-input" placeholder="First Name">
                </div> 
                 ';
        ?>

and this is working fine.But the problem is when i am trying to validate the form using jquery its not validating. EDIT : okay now i know that in validation each and every rule name should be unique.but how to do that ? As i do not know the number of fields

'firstname[1]': {
                required: true,
                minlength: 2
                },
 'firstname[2]': {
                required: true,
                minlength: 2
                },
 'firstname[3]': {
                required: true,
                minlength: 2
                },

this is a sample rule for three fields how can i set up a loop in there for 10 fields ?

  • 写回答

2条回答 默认 最新

  • dpwle46882 2014-12-28 09:41
    关注

    There may be more than one reason, but the thing I see is that your ID's are not unique, you should set the id value the same as you have done so with the name.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?