weixin_33722405 2015-03-23 19:43 采纳率: 0%
浏览 10

Zurb基金会遵守问题

Cannot get my form to submit using the Foundation 5 Abide code. If it take out the validation the code/ajax form submits perfectly. See code below, I'm sure I'm missing something. The form is only checking for valid email addresses right now, though I will add in checking for the first name and last name fields later if I can get this one validation to work first.

Form:

<form method="post" name="adduser" id="adduser" data-abide="ajax">
<fieldset>
<legend>Add New User</legend>    

<div class="small-2 columns">
<label class="inline">First Name
<input type="text" name="fname"/>
</label>
</div>

<div class="small-2 columns">
<label class="inline">Last Name
<input type="text" name="lname"/>
</label>
</div>

<div class="small-4 columns">
<label class="inline">Email
<input type="email" name="email"/>
</label>
</div>

<div class="small-2 columns">
<label class="inline">Access Type
<select  name="accesslvl">
<option value="1" selected>User</option>
<option value="2">Admin</option>
</select>
</label>
</div>

<div class="small-2 columns">
<input type="submit" class="button small adduserbtn" value="Add User" />
</div>
</fieldset>
</form>

Script:

$('#adduser').on('valid.fndtn.abide', function() {

     $.ajax({
          type: 'post',
          url: 'addnewuser.php',
          data: $('form').serialize(),
          success: function () {
               alert('User has been added successfully');
               window.location.reload(true);
          }
      });
});

Previous to adding the validation into the equation, I was submitting the form via this script, which was working fine and still does work when I remove the data-abide settings from the form.

 $('form').on('submit', function (a) {

      a.preventDefault();

      $.ajax({
        type: 'post',
        url: 'addnewuser.php',
        data: $('form').serialize(),
        success: function () {
          alert('User has been added successfully');
          window.location.reload(true);
        }
      });

    });

  });
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Stata链式中介效应代码修改
    • ¥15 latex投稿显示click download
    • ¥15 请问读取环境变量文件失败是什么原因?
    • ¥15 在若依框架下实现人脸识别
    • ¥15 添加组件无法加载页面,某块加载卡住
    • ¥15 网络科学导论,网络控制
    • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
    • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
    • ¥15 关于arduino编程toCharArray()函数的使用
    • ¥100 vc++混合CEF采用CLR方式编译报错