0

When I click enter on the textarea in buttom formgroup the remove method defined top form group gets called . Not sure why and how can this be avoided ? I had added a ngkeyup event on the textarea even still then the remove method gets called when I enter on the textbox .

<div class="form-group" name="form-group1">
    <label class="col-sm-2 control-label">{{col1label}}</label>
    <div class="col-sm-6">
        <div ng-repeat="label in list">
            <div class="col-sm-6">
                <div class="input-group">


                    <input type="text" class="form-control" ng-model="label.name">

                    <span class="input-group-btn">
                        <button type="submit" class="pull-right btn btn-white" name="btn" ng-click="remove(label.name)">
                            <i class="fa fa-trash"></i>
                        </button>
                    </span>


                </div>
            </div>
            <div class="col-sm-8"></div>

        </div>
    </div>
    </div>
<div class="form-group" name="form-group2">

    <label class="col-sm-2 control-label">{{column2label}}</label>
    <div class="col-sm-6">
        <div class="input-group">
            <input type="text" class="form-control" ng-model="text" name="textarea" placeholder="{{col2placeholder}}">
            <span class="input-group-btn">
                <button type="submit" class="pull-right btn btn-white" name="addButton" ng-click="addvalue()">
                    <i class="fa fa-plus-square"></i>
                </button>
            </span>
        </div>

    </div>

</div>

Found the answer . made the button type as button instead of submit .This prevented enter event being triggered . button type="button" class="pull-right btn btn-white" name="addButton" ng-click="addvalue()">

  • Think you need to prevent ENTER to submit your form. maybe this will help you http://stackoverflow.com/questions/4221464/disable-enter-key-on-page-but-not-in-textarea – Zivko Apr 23 '15 at 15:18
  • thanks for help..is there any way we can avoid this using angular or html attribute . We are avoiding use of jquery or dom manipulation by javasicript as much as possible..so the above solution does not help me . – Sushil Nayak Apr 23 '15 at 15:24
  • @SushilNayak: Congrats on "Found the answer". But please, __post as answer__. This way everyone could benefit and search (e.g. DuckDuckGo Instant-Anwer, etc.). I will give you an upvote to your answer ️ – hc_dev Mar 10 '21 at 06:02

0 Answers0