<div class="well">
<div class="panel-title>
<span class="fa fa-caret-right" ng-if="!showGeneral"></span>
<span class="fa fa-caret-down" ng-if="showGeneral"></span>
</div>
<label>GENERAL</label>
<div ng-if="generalFormName.$valid" class="pull-right">
<i class="fa fa-check" style="color:#4cc94c;font-size:large;"></i>
</div>
<div class="panel-collapse" ng-if="showGeneral">
<general></general>
</div>
</div>
<div>
<form name="generalFormName" novalidate autocomplete="off">
<input type="text" class="form-control align" required ng-model="infor.name" />
</form>
</div>
The directive general is another html. When the required fields in that form are filled in by the user I need a check mark to displayed to the right of the label. I do not have any button to submit and send the form data and then check for validation. I just need a check mark when formname.$valid. I added an ng-if but for some reason I am not able to get it.
Can someone help me out on this? Would be of great help .
Thanks in advance.
A form in Angular makes its validation state available through its name and only to its scope and the descendant scopes. Currently the <general> directive is outside the form's scope, so it cannot access the validation data. The simplest solution is to reposition the form to enclose both the input(s) and the <general> directive:
<form name="generalFormName" novalidate autocomplete="off">
<div class="well">
...
<general></general>
...
</div>
<div>
<input type="text" class="form-control align" required ng-model="infor.name" />
</div>
</form>
If the <form> must absolutely stay where it is, you can wrap it with an ng-form and use the ng-form's validity in <general>:
<div ng-form="ngFormName">
<div class="well">
...
<general valid="ngFormName.$valid"></general>
...
</div>
<div>
<form name="generalFormName" novalidate autocomplete="off">
<input type="text" class="form-control align" required ng-model="infor.name" />
</form>
</div>
</div>
The validity of the inner generalFormName affects the validity of the wrapper ngFormName.
If neither solution works (I don't see a reason why), you can always create a directive that publishes the validity of its adjacent form to a variable in the parent scope. Using variables in the parent scope is tricky, and I believe the previous solutions should be adequate, so I will not go in details. Instead of a variable, it could invoke a callback function - expect less surprises.
Related
icheck-bootstrap is a pure css checkboxes and radio buttons for Twitter bootstrap. This implies it will work with any of the frontend libraries. At least that's the way I figured it... And indeed, his use from the readme of his github page for the library :Link to icheck-bootstrap demo with docs Does work it just has a side effect that I can live with.
In at lease one place where I'm trying to use this library, the component is in a modal dialog that is used to login to the site. Below is the html template code for the component:
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true" (click)="hideModal()">
<span aria-hidden="true">×</span>
</button>
<h3 class="modal-title-site text-center"> Login to Rove </h3>
</div>
<form #f="ngForm" (ngSubmit)="onSubmit()">
<div class="modal-body">
<div class="form-group login-username">
<div>
<input name="log" id="login-user" class="form-control input" size="20"
[(ngModel)]="model.email" placeholder="Enter User Email" type="email">
</div>
</div>
<div class="form-group login-password">
<div>
<input name="Password" id="login-password" class="form-control input" size="20"
[(ngModel)]="model.password" placeholder="Password" type="password">
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<span class="checkbox login-remember">
<input name="rememberme" value="forever" checked="checked"
[(ngModel)]="model.rememberMe" type="checkbox">
<label for="rememberme">Remember Me</label>
</span>
</div>
</div>
<div>
<div>
<input name="submit" class="btn btn-block btn-lg btn-primary" value="LOGIN" type="submit">
</div>
</div>
</div>
</form>
<div class="modal-footer">
<p class="text-center">
Not here before? <a data-toggle="modal" data-dismiss="modal"
href="#ModalSignup">Sign Up.</a> <br>
Lost your password?
</p>
</div>
The code above is without the icheck-bootstrap implemented code. Below I have changed the key lines of code that will implement the checkbox as per the readme documention on the github site
<div class="icheck-success checkbox login-remember">
<input id="rememberme" value="forever" checked="checked"
[(ngModel)]="model.rememberMe" type="checkbox">
<label for="rememberme">Remember Me</label>
</div>
this code works as per the readme, unfortunately, after the dialog has been closed the modality of the modal dialog stays and the main page behind it will not allow any input from keyboard or mouse.
Note the input tag in the effective lines, I have change from the name attribute, to the id attribute. That seems wrong to me but, it is as the documentation suggests and, the only way it will completely work. If I do not change the attribute from name to id the checkbox changes to the correct style but it will not check to show a true state. In fact if I remove the icheck-success class from the class attribute of the above div line the behavior is identical and the component will still not take input after the dialog box has been closed if I use the id attribute instead of the name attribute.
I'm using Angular V9 and the dialog component that I am using is from the Valor Software ngx-bootstrap library and, as stated, it works perfectly when I code the html input tag with the name attribute. Does any know of a workaround or possibly what is happening here? the styling is what I want on the site but not at the cost of not having the login dialog effectively lock the site up after you login.
Thanks for any info that you may have on this issue.
I have fix the problem I was having. The first part of the problem was that I was not asking the right question. I have edited the question to ask it in a better way, I think.
I have fixed the problem with the html below:
<div class="icheck-success checkbox login-remember">
<input id="rememberme" name="rememberme" [(ngModel)]="model.rememberMe" type="checkbox">
<label for="rememberme">Remember Me</label>
</div>
it seems I had to have a name attribute in the input tag for some reason that I'm not clear about at all but, this is what I did to get the modal dialog to truly clear from the page after close.
I am writing an Angular application which uses ASP.Net Core as a backend, and bootstrap 4 and ngx-bootstrap for styling.
For some reason on all my HTML <label> tags (in every component/html file AND even though I have ID and Name attributes that match the "for" attribute of the <label> tag), the ID's are not found or recognized. I verified this by running the HTML through chrome dev tools lighthouse audit. Here is a sample of the code:
<div class="modal-header">
<h4 class="fa-pull-left modal-title" id="modalTitle">{{title}}</h4>
</div>
<div class="modal-body" id="modalBody">
<form id="modalForm">
<div class="form-group">
<label for="swName">Name</label>
<input id="swName" name="swName" [(ngModel)]="switchman.Name" class="form-control" type="text" />
</div>
<div class="form-group">
<label for="eid">EID</label>
<input [(ngModel)]="switchman.Eid" class="form-control" id="eid" name="eid" type="text" />
</div>
<div class="form-group">
<label for="homeOffice">Home Office</label>
<input [(ngModel)]="switchman.HomeOffice" class="form-control" id="homeOffice" name="homeOffice" type="text" />
</div>
<div class="modal-footer">
<button (click)="accept()" class="btn btn-success mr-auto" type="button">
Submit
</button>
<button (click)="reject()" class="btn btn-danger" type="button">
Cancel
</button>
</div>
In this section for example:
<form id="modalForm">
<div class="form-group">
<label for="swName">Name</label>
<input id="swName" name="swName" [(ngModel)]="switchman.Name" class="form-control" type="text" />
</div>
The <input> attribute of id="swName matches the for="swName" attribute of the <label> tag, but it isn't being applied at all, as if the id="swName" does not exist.
How do I get the label to recongize the ID of the input tag?
This actually turned out to be an issue with Resharper not correctly seeing the ID/For relationship. After further testing using Chrome Dev Tools and Lighthouse, I realized that I did have a few other unrelated ID tags that were truly unresolved.
Once I resolved these, the errors in Lighthouse went away, but my IDE still showed errors. I have submitted a ticket to the JetBrains/ReSharper team. Screenshots attached.
IDE: Visual Studio Enterprise 2019 16.5.1
ReSharper: 2020.1 EAP 5
OS: Win 10
Link to issue: https://youtrack.jetbrains.com/issue/RSRP-478855
UPDATE: JetBrains/ReSharper were able to recreate the issue and confirm that this is a bug that will be fixed in a future release.
Screens:
What I have: Im developing in Laravel 5.3 and calling an API with vue.js. The workaround is I submit the form with vue.js, make a call to the API and returned a token if all ok.
Problem: Google Chrome dont remember my login credentials after an sucessfull login (Edge, Firefox and Safari yes).
What I try: Like I have seen in other questions in StackOverflow (Mostly here), I have put a name attribute to the tags (Even if I use email instead of username). Don't use prevent of vue.js. Do all the login and finish with an .submit(); No one works in Chrome.
My code:
<form id="loginForm" class="form-horizontal m-t-20" v-on:submit.prevent="login" action="{{secure_url('/')}}" autocomplete="on">
<div class="form-group">
<div class="error col-xs-12"></div>
</div>
<div class="form-group ">
<div class="col-xs-12">
<input name="username" class="form-control" v-model="email" type="text" required="" placeholder="{{Lang::get('general.email')}}">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<input class="form-control" name="password" v-model="password" type="password" required="" placeholder="{{Lang::get('general.password')}}">
</div>
</div>
<div class="form-group text-center m-t-40">
<div class="col-xs-12">
<button class="btn btn-primary btn-block text-uppercase waves-effect waves-light" type="submit">{{Lang::get('general.logIn')}}</button>
</div>
</div>
</form>
Thanks for your time and help.
That means that you probably missing either field name or field ID
To be sure that it will work in all browsers be sure to provide both, even if name should be enough.
If your code is correct, make sure that you initialize your v-model variables.
Also, you should not use form while using Vue as you do not need input data bundled into the form as Vue model is handling that.
I am trying to make a basic log in system. I am mixing and matching bootstrap. Signing in layout is done. When I click on sign up, it takes me to another form field and it also works. For some reason when I click on forgot password, it should take me to forgot password page but it does not and nothing happens. I have the "forgotten password" page an ID but whenever I put that ID, the sign in stops working and format messes up.
Here is my code. I added js/css bootstrap code also.
http://jsfiddle.net/8cjrj118/1/
Here is my part of my code for the forgotten password form. I took off the id of "forgotten home" from main page because it was messing everything up.
<div style="display: none;" id="form-olvidado">
<h4 class="">
Forgot your password?
</h4>
<form accept-charset="UTF-8" role="form" id="login-recordar" method="post">
<fieldset>
<span class="help-block">
Email address you use to log in to your account
<br>
We'll send you an email with instructions to choose a new password.
</span>
<div class="form-group input-group">
<span class="input-group-addon">
#
</span>
<input class="form-control" placeholder="Email" name="email" type="email" required="">
</div>
<button type="submit" class="btn btn-primary btn-block" id="btn-olvidado">
Continue
</button>
<p class="help-block">
<a class="text-muted" href="#" id="acceso"><small>Account Access</small></a>
</p>
</fieldset>
</form>
Try this:
Forgot password?
DEMO
DEMO
$('#forgot').click(function(){
$('#form-olvidado').css(
"display","block"
);
$('#loginbox').css(
"display","none"
);
});
OR
$('#forgot').click(function(){
$('#form-olvidado').show();
$('#loginbox').hide();
});
Add forgot as id to anchor tag which says forgot password ?
then add this code
Secondly two methods can be used one is using css display block or none in jquery or
Hide or show both does the trick
Another thing regarding using jsfiddle In left side menu there is a tab called external resources you have to add css and other javascript files in that menu
Go to this site it has all bootstrap and other files hosted so that it can be used on the fly
At the time of given the input in edittext field it show error if anyone will put incorrent IP Address format of IP adsress should be like these 000.000.0.000 plz help me out
IN HTML5:-
<div data-role="content">
<form id="form">
<div data-role="fieldcontain">
<label for="ip">IP Address/System Name</label>
<input name="ip" id="ip" type="text" pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$">
</div>
<div style="text-align:center;">
<div data-role="button" data-theme="b" data-inline="true" id="button1">Update</div>
</div>
</div>
For HTML5 validation to work on submit, You have to put required attribute in your input fields, you want to validate using HTML5 and you have to submit the form.
You can handle the form data submitted through javascript, and incase you do want to handle the submitted data manually then you have to specify data-ajax="false" in you form tag
For your code, try this
<div data-role="content">
<form id="form" data-ajax="false">
<div data-role="fieldcontain">
<label for="ip">IP Address/System Name</label>
<input name="ip" id="ip" type="text" required pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$">
</div>
<div style="text-align:center;">
<input type="submit" value="Submit button" />
</div>
</form>
</div>
And in javascript you can do something like
$("#form").submit(function(e){
e.preventDefault();
//call your method
});
One route you can go uses mask.js - In your case you can have it force the user to input their data in the proper format, pre-populate the '.' characters in the IP, and stop the user from entering non-numeric values.
Mask.js
And here is a fiddle - http://jsfiddle.net/QF9Lz/2/
click in the textbox, you'll see a formatting mask appear and you will only be able to enter numeric values in the format you specified.
So, once you include mask.js in the head, you can initialize the input mask like this:
$(document).ready( function() {
$('#ip').mask('999.999.9.999');
});
I made this regex for address/mask
For example: 10.0.0.0/8
((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){3}\/([1-2][0-9]|[0-9]|3[0-2])$
if you want just the regex of address use:
((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){3}$