在表单提交时从URL中剥离锚标记

时间:2012-10-22 12:35:55

标签: jquery expressionengine zurb-foundation

Freeform版本:4.07 ExpressionEngine v2.5.3 - 构建日期:20120911

我在jQuery选项卡中有一个自由格式表单。当表单与erros一起提交时,该标签的锚点将从URL中删除。这会将我带回第一个选项卡而不是带有表单的选项卡。有没有办法将用户重定向回表单选项卡?

谢谢

<li id="qaTab">
  {exp:freeform:form
  form_id="2"
  required="name|email|user_message"
  return="contact_us/thank_you"
  recipients="yes"
  recipient1="Happy Harry|h_harry@somemail.com"
  recipient2="Lazy Larry|lazyl63@somemail.com"
  recipient_template="contact_form"
  notify_user="yes"
  user_email_field="user_email"
  inline_errors="yes"
  }
   {if freeform:general_errors}
    <h2>There were some error(s) with your submission:</h2>
   <ul>
   {freeform:general_errors}
    <li>{freeform:error_message}</li>
   {/freeform:general_errors}
   </ul>
   {/if}
   <div class="row">
    <div class="six columns">
     <label>{freeform:label:name}</label>
     {freeform:field:name}
     {if freeform:error:name}<small class="error">{freeform:error:name}</small>{/if}
    </div>
    <div class="six columns">
     <label>{freeform:label:email}</label>
     {freeform:field:email}
     {if freeform:error:email}<small class="error">{freeform:error:email}</small>{/if}
    </div>
   </div>
   {freeform:label:user_message}
   {freeform:field:user_message}
   {if freeform:error:user_message}
   <small class="error">{freeform:error:user_message}</small>{/if}
   <input type="hidden" name="subject" value="{title}" id="subject">
   <input type="submit" name="submit" value="Submit" id="submit" class="button">
  {/exp:freeform:form}
 </li> 

1 个答案:

答案 0 :(得分:5)

你应该使用jQuery解决这个问题:

  1. 检查是否存在类错误
  2. 如果存在:打开表单
  3. 其他:什么都不做
  4. 这将是:

    if ($(".error").length > 0) {  
        $("#tabs").tabs("select", "#qaTab");
    }
    
    祝你好运!