# Form validation through submit dosen't works from \<ion-nav-buttons\>

**URL:** <https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841>\
**Category:** ionic-v1\
**Created:** [December 9, 2014, 11:13pm UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841 "2014-12-09T23:13:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaolong97427](https://avatars.discourse-cdn.com/v4/letter/x/eada6e/32.png) [@xiaolong97427](https://forum.ionicframework.com/u/xiaolong97427)\
**Post date:** [December 9, 2014, 11:13pm UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841/1 "2014-12-09T23:13:00Z")

</div>

Hi,

Following information from : [How to do Validation with angular JS/ionic Framework](http://forum.ionicframework.com/t/how-to-do-validation-with-angular-js-ionic-framework/265/36), I successfully created a form that is validated (or not) after the click on a button submit.

My problem is that this submit has to be in the of the page. I need this submit to be in the . Is there a way to make the click on the submit to execute the form validation and to sbmit the form if every is all right ?

```
<form novalidate="novalidate" on-valid-submit="addPoLine(true)" name="form_poLine" id="form_poLine">

<ion-view title="Select Product">
<ion-nav-buttons side="right">
        <button class="button" ng-click="updatePoline()" ng-hide="addMode">Modify</button>
    	<button type="submit" class="button button-block" ng-show="addMode">Add NOK</button>
 </ion-nav-buttons>
 <ion-content>	
        <button type="submit" class="button button-block" ng-show="addMode">Add OK</button>
...

```

Th first button Add Nok doesn’t work but the second button Add OK do works. what(s wrong with my first submit button ?

Regards,

Xiaolong

---

<div class="post-metadata">

**Author:** ![davor](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@davor](https://forum.ionicframework.com/u/davor)\
**Post date:** [December 10, 2014, 7:00pm UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841/2 "2014-12-10T19:00:21Z")

</div>

Maybe a little different aproach, but when I have forms and use validation, I disable submit button until the form is valid. This is easiley done by adding ng-disabled to your button, something like this

```
ng-disabled="form_poLine.$invalid"

```

once the form is valid the button will become enabled, then you don’t need to run custom validation in your controller. Check Angular forms [https://docs.angularjs.org/guide/forms](https://docs.angularjs.org/guide/forms) (Custom validation) to how to setup your validation in your inputs.

Davor

---

<div class="post-metadata">

**Author:** ![ajbraus](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ajbraus/32/63991_2.png) [@ajbraus](https://forum.ionicframework.com/u/ajbraus)\
**Post date:** [December 17, 2014, 9:38pm UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841/3 "2014-12-17T21:38:00Z")

</div>

This would be great, except that $invalid doesn’t work if its outside of the tag. So can’t go in the header. . . This would be a great feature because almost all apps have the save button in the upper right.

---

<div class="post-metadata">

**Author:** ![davor](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@davor](https://forum.ionicframework.com/u/davor)\
**Post date:** [December 17, 2014, 10:04pm UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841/4 "2014-12-17T22:04:33Z")

</div>

I solved that issue wrapping entire section (buttons and content) with form tag 🙂 hope it helps

---

<div class="post-metadata">

**Author:** ![xiaolong97427](https://avatars.discourse-cdn.com/v4/letter/x/eada6e/32.png) [@xiaolong97427](https://forum.ionicframework.com/u/xiaolong97427)\
**Post date:** [December 18, 2014, 3:19pm UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841/5 "2014-12-18T15:19:10Z")

</div>

thank you davor for another possible way to solve the validation needs.

But I need to let the user see what are the uncompleted field.

---

<div class="post-metadata">

**Author:** ![xiaolong97427](https://avatars.discourse-cdn.com/v4/letter/x/eada6e/32.png) [@xiaolong97427](https://forum.ionicframework.com/u/xiaolong97427)\
**Post date:** [December 18, 2014, 3:28pm UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841/6 "2014-12-18T15:28:03Z")

</div>

I also wraped the and the by . As you can see in my code, is in the first line.

Did you handle the validation manually in the controller checking all the field ?

---

<div class="post-metadata">

**Author:** ![ceckman](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ceckman/32/13771_2.png) [@ceckman](https://forum.ionicframework.com/u/ceckman)\
**Post date:** [October 24, 2015, 12:08am UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841/7 "2015-10-24T00:08:12Z")

</div>

Has anyone figured out a way to use ng-disabled if the button is outside form tag? I’ve got a button in an ion footer bar.

---

<div class="post-metadata">

**Author:** ![johnw86](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/johnw86/32/100569_2.png) [@johnw86](https://forum.ionicframework.com/u/johnw86)\
**Post date:** [May 18, 2016, 10:39am UTC](https://forum.ionicframework.com/t/form-validation-through-submit-dosent-works-from-ion-nav-buttons/13841/8 "2016-05-18T10:39:00Z")

</div>

You can try using the form attribute on your button. [http://caniuse.com/#feat=form-attribute](http://caniuse.com/#feat=form-attribute)

Make sure the value matches the id of your form.
