1

This problem is really annoying me.

In this simple form:

<form data-abide novalidate method="POST">
  <label>First name
  <input type="text" name="firstname" required> 
  </label>
  <input type="submit" value="Save">
</form>

I'm trying to add a new field and make Foundation check it.

$('<label>Last Name<input name="lastname" type="text" required></label>').insertBefore('input[type=submit]').foundation();

Example here: https://jsfiddle.net/wcLmb3y9/

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Renato Galvones
  • 533
  • 1
  • 3
  • 14

1 Answers1

6

Found it guys!!!

Just add a

Foundation.reInit('abide');

Right after the html you've included and vóila!

Hope it helps more guys!

lml

Renato Galvones
  • 533
  • 1
  • 3
  • 14
  • I found that in addition to this code, I had to rebind the **'forminvalid.zf.abide'** and **'formvalid.zf.abide'** (Foundation 6.4.3), like this : *$('formWithDynamicallyAddedFields').on('forminvalid.zf.abide',function(e){alert('invalid');}).on('formvalid.zf.abide',function(e){alert('valid');});* – AlexLaforge Sep 22 '18 at 23:24