-1

For some reason, when I hit the "cancel" button, the textarea receives 26 spaces before any text currently in it and a carriage return after it. This is when the cancel button is styled traditionally (HTML only) as such:

<button type="reset" name="reset" class="btn btn-default" value="Cancel">Cancel</button>

When I add in my AngularJS directive (ng-click), it removes the text, but still adds the spaces and carriage return:

<button type="reset" name="reset" class="btn btn-default" value="Cancel" ng-click="vm.resetFields()">Cancel</button>

If I remove the "value" attribute from the cancel button, the form submits regardless of the state of validation, but the cancel button behaves normally otherwise. This means that it submits a completely blank form and on reload of form (via back-button or the button that says "retry") it shows up completely empty (the data is persisted through a data service) as would be expected.

The textarea is styled with AngularJS, and I have not changed it throughout these cancel button reconfigurations. Its configuration is below:

<textarea ng-model="vm.issue" id="issue" name="issue" placeholder="Enter a description" wrap="hard" rows="5" ng-required="true" ng-minlength="10"
   class="form-control skinny" ng-maxlength="500" ng-pattern="/^[a-z 0-9-.,?!']{10,500}$/i">{{vm.issue}}</textarea>

Any suggestions for stopping this spatial inclusion that don't also submit an empty form?

CSS
  • 412
  • 5
  • 17

1 Answers1

1

Change the button type

<input type="button" name="reset" class="btn btn-default" value="Cancel" ng-click="vm.resetFields()" />
  • any reason behind it ? – BhagyashriK Jul 30 '15 at 17:47
  • Wonder where the down vote came from... Wait, I see it. You changed to and forgot to remove the closing tag and the word "Cancel". Slightly sloppy there, but thanks for the solution to my problem. – CSS Jul 30 '15 at 18:28