I have a wedding RSVP form
I am trying hide the DONE submit button and only show it when the form is valid.
<form method="POST" action="http://l.bheng.com:8888/wedding" accept-charset="UTF-8" class="ng-pristine ng-pristine ng-valid ng-valid-required ng-valid-email" role="form" id="rsvp-form" name="rsvp-form">
<input name="_token" type="hidden" value="JK8PC04aF7xGsbcQoTvzz2FV61od1DmGdraiZNwB">
<div class="col-xs-12 form-group">
<label for="">Are you attending ? </label>
<br>
<label for="going">
<input type="radio" id="going" value="1" ng-model="going" class="ng-pristine ng-untouched ng-valid ng-not-empty" name="3"> Yes
</label>
<label for="going">
<input type="radio" id="going" value="0" ng-model="going" class="ng-pristine ng-untouched ng-valid ng-not-empty" name="4"> No
</label>
</div>
<div class="col-xs-12 form-group">
<label for="">Number of total guests ? </label>
<br>
<select id="guestNum">
<option value="1">Just Me</option>
<option value="2">Me and My +1</option>
</select>
</div>
<div class="col-xs-12 form-group">
<label for="">Name</label>
<input type="text" class="normal ng-pristine ng-untouched ng-valid ng-empty ng-valid-required" id="name" placeholder="Name" ng-model="name" ng-required="required">
</div>
<div class="col-xs-12 form-group">
<label for="">Email</label>
<input type="email" class="normal ng-pristine ng-untouched ng-valid ng-empty ng-valid-email ng-valid-required" placeholder="Email Address" id="email" ng-required="required" ng-model="email">
</div>
<div class="col-xs-12 form-group">
<label for="">Message</label>
<textarea id="message" ng-model="message" rows="5" type="text" class="normal ng-pristine ng-untouched ng-valid ng-empty" placeholder="Message to us "></textarea>
<grammarly-btn>
<div data-reactroot="" class="_e725ae-textarea_btn _e725ae-anonymous _e725ae-not_focused" style="visibility: hidden; z-index: 2;">
<div class="_e725ae-transform_wrap">
<div title="Protected by Grammarly" class="_e725ae-status"> </div>
</div>
</div>
</grammarly-btn>
</div>
<div class="col-xs-12" ng-hide="rsvp-form.name.$invalid || rsvp-form.email.$invalid ">
<a id="rsvp-submit" ng-click="rsvp()" class="button" style="width: 100%;">
Done
<img src="/img/svg/default.svg" alt="Loading" style="width: 30px; float: right; padding-top: 7px; " class="hidden loading">
</a>
</div>
</form>
My Done button keep showing no matter what.
How do I stop that ?
How can my form have this class ?
ng-pristine
ng-valid
<--- How is it possible ? I'm not even input anything in name/emailng-valid-required
<--- How is it possible ? I'm not even input anything in name/emailng-valid-email
<--- How is it possible ? I'm not even input anything in name/email
JSfiddle = https://jsfiddle.net/bheng/Ln3tqzcu/
ng-hide
is looking in the wrong place for data to validate, since your model for 'name', for example, is stored in the scope asname
and not inside the objectrsvp-form
, but a fiddle can help debugging ;)ng-pristine ng-pristine ng-valid ng-valid-required ng-valid-email
in the original html??view page source
.ng-model="going"
?