How does this HTML block the auto insertion of my email address from chrome? - html

At first I thought it was some jerk move to make me type my username for added "security" on top of 2FA so I decided to fix it with tampermonkey and remove the autocomplete="off" attribute only to discover that there wasn't one.
Why does Chrome not offer to autofill the email input in this form? This is a link to the site.. But this is the form that is blocking autocomplete on the email address.
<form method="post" class="form-horizontal">
<h1 class="paste-page-header">Log in</h1>
<div class="form-group">
<div class="col-md-24">
<label class="paste-input-label">Email</label>
<div class="paste-input-wrapper">
<input type="text" id="email" name="email" placeholder="Email" tabindex="1" required="true" class="paste-input sl_whiteout" autofocus="autofocus" maxlength="255">
</div>
</div>
</div>
<div class="form-group col-md-24">
<button role="login-button" type="submit" tabindex="2" class="paste-primary-button" data-loading-text="<i class='icon icon-spinner icon-spin'></i>" value="Log in">Next
</button>
</div>
<span class="paste-text">Don’t have an account yet? Sign up for free.</span>
<input inert="" readonly="true" type="password" id="password" name="password" tabindex="50" style="opacity: 0.02;" aria-label="This is a hidden password field for compatibility with password managers. Please ignore this field.">
<input type="hidden" name="g" value="/console/sms/dashboard?" class="sl_whiteout">
<input type="hidden" name="t" value="182b71c36e3bb0a0a788ab671fbe875c7b46602de5f49fb3e441645b8848a76a" class="sl_whiteout">
<input type="hidden" name="CSRF" value="2869689c41323f2456ec6558c8ee7f3e4c409eda3bbed69bf10228f752a293e4" class="sl_whiteout">
</form>
After you type your email address, it will allow you to autocomplete the password, it's just this field that is a problem. And I tried this:
> x = document.getElementById('email')
<input type=​"text" id=​"email" name=​"email" placeholder=​"Email" tabindex=​"1" required=​"true" class=​"paste-input sl_whiteout" autofocus=​"autofocus" maxlength=​"255">​
> x = document.getElementById('email')
x.autocomplete
''
So, they aren't disabling it with JS (at least not in any way that I can see.....
I'm asking so that I don't make this mistake on any of my sites and because I'm really curious how they pulled this off.

Related

How to trigger form input pattern validation without submitting?

I have a form:
<form action="/index.html" method="POST" id="form">
<div id="namediv">
Full Name:
<input type="text" pattern="[A-Z][a-z]+ [A-Z][a-z]+"/ id="name" required/></div>
<div>
Date:
<input type="date"/>
</div>
<div id="emaildiv">
Email:
<input type="email" id="email" onblur="validateEmail()" required/><br>
<emailerror class="invisible">Incorrect email address!</emailerror>
</div>
<div id="urldiv">
Favorite webpage:
<input type="url" name="favurl"id="url" onblur="validateFavURL()" required/><br>
<urlerror class="invisible">Incorrect webpage!</urlerror>
</div>
<div>
<input type="button" value="Validate" onclick="validateAll()"/>
</div>
</form>
How can I trigger the name's pattern validity without submitting the form? I tried checkValidity() but didn't succeed. What is the exact syntax for it?
Not sure that I clearly understand the question. But the problem appears to be invalid regex. But the field does say "full name" so you'd likely need to allow a space as well.
<div>
<label>This field accepts upper and lowercase letters only</label>
</div>
<input type="text" pattern="[A-Z][a-z]+" id="name" required/>

What's the language and redirect inputs mean in the form?

When I am reading code in browser:
<div class="login-body">
<h2>Please type your password</h2>
<form method="post" action="/admin/dologin.php">
<input type="hidden" name="language" id="inputLanguage" />
<input type="hidden" name="redirect" value="/admin/" />
<div class="form-group">
<input type="text" name="username" class="form-control" placeholder="Username" autofocus />
</div>
<div class="form-group">
<input type="password" name="password" class="form-control" placeholder="Password" />
</div>
redirect in the form's function, whether when I write a custom form, this input will write too?
It is just submitting the form to /admin/dologin.php, with one field with the name of redirect and value as /admin/
If you check the code of /admin/dologin.php, there must be some if statement working on the $_POST['redirect'], which is a post superglobal, and has a value /admin/
This form will always submit this value since it is hardcoded and is hidden so no one can change it explicitly.
I Hope this clears your doubt!

Chrome warning "[DOM] Password forms should have (optionally hidden) username fields for accessibility" in console even with hidden username field

When visiting the "reset password" route of my single-page app and looking at the Chrome browser console, I am greeted with the follwing warning:
[DOM] Password forms should have (optionally hidden) username fields for accessibility: (More info: goo.gl/9p2vKq)
Helpfully, the html of the form in question is also printed to the console in the next line, and quite clearly contains a hidden username field:
<form data-ember-action data-ember-action-436=​"436">​
<div class=​"form-group">
<label for=​"newpasswordone">​Password​</label>​
<input type=​"password" autocomplete=​"new-password" placeholder=​"Enter your new password" id=​"ember437" class=​"form-control ember-text-field ember-view" data-op-id=​"0">​
<label for=​"newpasswordtwo">​Password (again)​</label>
​<input type=​"password" autocomplete=​"new-password" placeholder=​"Re-enter your new password" id=​"ember438" class=​"form-control ember-text-field ember-view" data-op-id=​"1">​
<input type=​"hidden" name=​"username" autocomplete=​"username" value=​"a_b">
​</div>​
<button disabled type=​"submit" class=​"btn btn-default">​Reset password​</button>​​
</form>​
I tried some minor variations -- unhiding the username field, marking it readonly, moving it outside the div -- without affecting the warning.
How does Chrome expect to be served the username?
Problem occurs with Chrome 63 and 64.
I had the same problem. After some digging, I found that it needs to be an input element with the type text. By "optionally hidden" they mean that you may hide it with CSS.
If you just add an input with the name email or username chrome gives you another warning saying that input elements should have autocomplete attributes. So this is what I came up with to fix these errors:
<input
type="text"
name="email"
value="..."
autocomplete="username email"
style="display: none;"
>
You will need to manually render the actual username or email into the elements value attribute.
Also, keep in mind that inline styles are not a very good practice.
Use the hidden attribute instead of type="hidden"
<input hidden type="text" autocomplete="username" value="{{...}}">
I had this same situation.
Everything seemed be ok but I still got this verbose.
On my case helped me a relocate this userName input from end of form to begin of that.
It was my code before my changes:
<form id="changePass">
<div class='modal-dialog'>
<input type="password" class="form-control" id = "changePasswordOldPassword" autocomplete="current-password"/>
<input type="password" class="form-control" id = "changePasswordNewPassword" autocomplete="new-password"/>
<input type="password" class="form-control" id = "changePasswordNewPassword2" autocomplete="new-password"/>
<div class="modal-footer">
<button type="button" id="change-password-ok-button">Ok</button>
<button type ="button" data-dismiss="modal">Close</button>
</div>
</div>
<input id="userName" name="username" autocomplete="username" value="">
</form>
And this is current code:
<form id="changePass">
<input id="userName" name="username" autocomplete="username" value="">
<div class='modal-dialog'>
<input type="password" class="form-control" id = "changePasswordOldPassword" autocomplete="current-password"/>
<input type="password" class="form-control" id = "changePasswordNewPassword" autocomplete="new-password"/>
<input type="password" class="form-control" id = "changePasswordNewPassword2" autocomplete="new-password"/>
<div class="modal-footer">
<button type="button" id="change-password-ok-button">Ok</button>
<button type ="button" data-dismiss="modal">Close</button>
</div>
</div>
</form>
you must put the input tag inside another tag for example:
<form action="">
<div>
<input type="text" autocomplete="username">
</div>
<div>
<input type="password" autocomplete="password">
</div>
<div>
<input type="password" autocomplete="password">
</div>
I had this same situation in VueJs when i use rendering conditional v-if v-else and i try put input tag inside new tag and it's work for me
Though I know that this question is quite old but thought maybe it may be useful for someone .I also faced the same issue with my React app update user password and this worked for me just above the password fields without label.Excuse me for writing the React way .
<input hidden type='text' name='email' autoComplete='email' />
Basic usage :-
<form>
<input hidden type='text' name='email' autoComplete='email' />
<label htmlFor="oldPass">Enter your current password</label>
<input id="oldPass" type="password" />
<label htmlFor="newPass">Enter your new password</label>
<input id="newPass" type="password" />
</form>
After reading Jonas comment I rebuilt the project and the warning went away
I had the same warning showing in the console and this is how I fixed it:
<input hidden autocomplete="username" name="username" type="text" value="{{..}}"/>
<input hidden autocomplete="email" name="email" type="text" value="{{..}}"/>

Chrome remembers postcode rather than Email/username

I am working on an MVC5 Web Application , I have a simple registration form containing Email , postcode and password. But when I register the chrome remembers the postcode and password rather than email and password; and next time when I try to enter email the postcodes appear as suggestions.
My markup for the form is as under:
I have edited the question and pasted the whole form. kindly suggest me what to do other than moving email and passwords up or down.
<div class="wrapper">
<div class="closeBetaWrapp">
<div class="simplePopup">
<div class="loginWrapp signupWrapp">
<div class="iconCont"><img src="images/orchaIcon.png" alt="Orcha"></div>
<form action="">
<div class="formrow ">
<div class="leftCol">
<label for="Email">Email</label>
<input class="formField" type="email" name="Email" id="Email" placeholder="Enter your email address here" />
</div>
<div class="leftCol">
<label for="Pcode">Postcode</label>
<input class="formField" type="tel" name="Pcode" id="Pcode" placeholder="Enter postcode here" />
</div>
<div class="leftCol">
<label>Year of Birth</label>
<select id="" class="dropdown">
<option>Choose your year of birth</option>
<option>1980</option>
<option>1981</option>
<option>1982</option>
<option>1983</option>
<option>1984</option>
<option>1985</option>
<option>1986</option>
<option>1987</option>
<option>1988</option>
<option>1989</option>
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>1993</option>
<option>1994</option>
<option>1995</option>
</select>
</div>
<div class="leftCol">
<label>Gender</label>
<select id="" class="dropdown">
<option>Choose your year of birth</option>
<option>Female</option>
<option>Male</option>
</select>
</div>
<div class="leftCol">
<label for="Password">Password</label>
<input class="formField" type="password" name="Password" id="Password" placeholder="Enter your password here" />
</div>
<div class="rightCol">
<label for="CPassword">Confirm Password</label>
<input class="formField" type="password" name="CPassword" id="CPassword" placeholder="Enter password again" />
</div>
</div><!-- formrow -->
<div class="formrow">
<div class="rightCol btnCol">
<input class="moreBtn" type="submit" value="Signup" />
<input class="moreBtn cnclBtn" type="reset" value="Cancel" />
</div>
</div><!-- formrow -->
</form>
</div>
</div>
</div><!-- closeBetaWrapp -->
Browsers detect passwords by form.elements[n].type == "password" and iterating through all the document. Then it detects the username field by searching backwards through form elements for the text field immediately before the password field.
So, In your case, It thinks your postcode as your username field and remembers this.
So, solution is to move the postcode field above the email field.
If even after moving, it doesn't work, delete previously saved postcode-password value from 'saved passwords' in chrome settings. Also delete any previously saved values by using down arrow key to select the suggestion and pressing shift + delete.
I got the information about how browsers detect username-password field here & here
You can use the autocomplete attribute to tell the browser what the field contains. For example:
<input class="formField" autocomplete="postal-code" type="text" name="PostCode" id="PostCode" placeholder="Enter your postcode here" />
See https://html.spec.whatwg.org/multipage/forms.html#autofill for more information.

Form not taking action

I have a problem with a form. It is not sending any action (page not even refreshing on click). If I copy the form in another document locally it has no problem, all working well, mail message being sent. Here is the code of the form:
<form method='post' name='ContactForm' id='contactForm' action='contact_main.php'>
<p>Your name:</p>
<input type="text" class="input-box" name="user-name" placeholder="Please enter your name.">
<p>Email address:</p>
<input type="text" class="input-box" name="user-email" placeholder="Please enter your email address.">
<p>Subject:</p>
<input type="text" class="input-box" name="user-subject" placeholder="Purpose of this message.">
<p class="right-message-box">Message:</p>
<textarea class="input-box right-message-box message-box" name="user-message" placeholder="Your message."></textarea>
<button type='submit' class='myinputbtn' name='submitf' id="submitf">Send your message</button>
<div id='message_post'></div>
<input type="hidden" name="contact">
</form>
Clicking the submit button results in... nothing!
Please let me know if I need to edit my question before downrating. Thanks!
Use
<input type="submit" ...
instead of a button (which is used with Javascript, not for form submitting)