Button html triggering active keyboard on IOS? - html

We have built a site with a login page - login page is a simple form in field sets - annoyingly when using an iPad the keyboard is triggered whenever pressing the button - it stays active as the next page is loaded - i can understand why - following is the form code - is there any way to disable this functionality?
<section>
<h3>Login</h3>
<form method="post" action="/Login" novalidate="novalidate" _lpchecked="1"> <fieldset>
<label class="ui-front legend icon-img-inside">
<label for="FormModel_UserName">User Name</label>
<input type="text" value="" name="FormModel.UserName" id="FormModel_UserName" data-val-required="Please provide your User Name" data-val="true" aria-required="true" aria-describedby="FormModel_UserName-error" class="input-validation-error" aria-invalid="true">
<span data-valmsg-replace="true" data-valmsg-for="FormModel.UserName" class="field-validation-error"><span id="FormModel_UserName-error" class="">Please provide your User Name</span></span>
<img alt="Icon: Person" src="/css/img/icons/icon-user.svg">
</label>
</fieldset>
<fieldset>
<label class="ui-front legend icon-img-inside">
<label for="FormModel_Password">Password</label>
<input type="password" name="FormModel.Password" id="FormModel_Password" data-val-required="Please provide your Password" data-val="true" aria-required="true" class="input-validation-error" aria-describedby="FormModel_Password-error">
<span data-valmsg-replace="true" data-valmsg-for="FormModel.Password" class="field-validation-error"><span id="FormModel_Password-error" class="">Please provide your Password</span></span>
<img alt="Icon: Pencil" src="/css/img/icons/icon-pencil.svg">
</label>
</fieldset>
<div data-valmsg-summary="true" class="validation-summary-errors"><ul> <li>Please provide your User Name</li><li>Please provide your Password</li> </ul></div> <fieldset>
<button class="button" name="submit" type="submit">
<i class="key"></i>
<span>Login</span>
</button>
</fieldset>
<!-- Javascript detection -->
<span class="result-login" id="result"></span>

You could try to disable native, default submit process and do submiting with js,, something like this:
document.getElementsByClassName('button')[0].onclick = function(e){
e.preventDefault();
document.getElementById('frm1').submit();
}
see the code here, I changed some tag names, look the html pane also..: http://codepen.io/mkdizajn/pen/EgmPQR?editors=1010
I can't see this live and test but I hope that helps..

Related

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

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.

Why does required attribute in html doesn't work?

I wanted to try and verify input before being submitted therefore I used the required attribute at the end of input, but it's not working and I've already tried some of the recommended solution like wrapping the input in form tag or trying to close the tag of input () but when i submit my form with an empty input it stills submited normally and doesn't declare a required field .
I would appreciate any help, thank you!!
this is a part of my code
<form id="form" style="background-color:honeydew ;" class="container text-center">
<div><br><h2> Contact Us </h2></div>
<div id="contact">
<div>
<label> Name</label>
<input type="text" placeholder="Your name " name="name" required/>
</div>
<br>
<div>
<label> Email</label>
<input type="email" placeholder="name#gmail.com" name="email" name="email">
</div>
<br>
<div>
<label> Message</label>
<input type="text" style="height:50px;" name="message">
</div>
<br>
<div><input type="button" value="submit" name="submit"><br></div>
<br>
</div>
<br>
</form>
and this is the javascript file linked to it :
//we take informations subbmitted by user from the form and we replace the form with a reply
//containing these pieces of information on the click on the submit button
var form=document.getElementById('form'),
contactForm=document.getElementById('contact'),
submitButton=contactForm.children[6].children[0];
var processForm= function(){
name=document.getElementsByName('name')[0].value,
email=document.getElementsByName('email')[0].value,
sitereplyText=document.createTextNode('this is a initialiazing value'),
sitereplyEl=document.createElement('p');
mytext= 'Hey '+name+'! Thanks for your message :) We will email you back at '+email;
sitereplyText.nodeValue=mytext;
sitereplyEl.appendChild(sitereplyText);
form.replaceChild(sitereplyEl,contactForm);
}
submitButton.addEventListener('click',processForm);
So i firstly corrected the input type into submit
<input type="submit" value="submit" name="submit">
then in the javascript file i changed
submitButton.addEventListener('click',processForm);
to
submitButton.addEventListener('form.submit()',processForm);
and it seems to work :)

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="{{..}}"/>

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)

Why did facebook used submit button and not just links for the like button?

I keep wondering why did facebook use like submit from button and not just simple link to do the action with, following is there like button code.
<form rel="async" class="live_184361748268334 commentable_item autoexpand_mode" method="post" action="/ajax/ufi/modify.php" data-live="{"seq":0}" onsubmit="return Event.__inlineSubmit(this,event)">
<input name="charset_test" value="€,´,€,´,水,Д,Є" type="hidden">
<input autocomplete="off" name="post_form_id" value="1ef694751d74ce24382cfa6181f1adfe" type="hidden">
<input name="fb_dtsg" value="_19R5" autocomplete="off" type="hidden">
<input autocomplete="off" name="feedback_params" value="{"actor":"514782389","target_fbid":"184361748268334","target_profile_id":"514782389","type_id":"17","source":"1","assoc_obj_id":"","source_app_id":"2309869772","extra_story_params":[],"content_timestamp":"1298066944","check_hash":"e76c88ca6e20b4a0"}" type="hidden">
<div class="UIImageBlock clearfix"><i class="UIImageBlock_Image UIImageBlock_ICON_Image img sp_4b2fk0 sx_b64365"></i>
<div class="UIImageBlock_Content UIImageBlock_ICON_Content"><span class="uiStreamSource"><abbr title="Saturday, February 19, 2011 at 3:09am" data-date="Fri, 18 Feb 2011 14:09:04 -0800" class="timestamp">4 hours ago</abbr></span><span class="UIActionLinks UIActionLinks_bottom" data-ft="{"type":"action"}"> ·
<button class="like_link stat_elem as_link" title="Like this item" type="submit" name="like" onclick="fc_click(this, false); return true;"><span class="default_message">Like</span><span class="saving_message">Unlike</span></button>
·
<label class="uiLinkButton comment_link" onclick="return fc_click(this);" title="Leave a comment">
<input value="Comment" type="button">
</label>
· <a title="Send this to friends or post it on your profile." href="/ajax/share_dialog.php?s=99&appid=2309869772&p%5B0%5D=514782389&p%5B1%5D=184361748268334" rel="dialog">Share</a></span></div>
</div>
<ul class="uiList uiUfi focus_target fbUfi" data-ft="{"type":"ufi"}">
<li class="ufiNub uiListItem uiListVerticalItemBorder"><i></i>
<input autocomplete="off" name="xhp_ufi" value="1" type="hidden">
</li>
<li class="ufiItem uiUfiLike">
<div class="UIImageBlock clearfix"><a class="UIImageBlock_Image UIImageBlock_ICON_Image" tabindex="-1">
<label onclick="this.form.like.click();"><i class="img sp_8dfqpl sx_4ac53f" title="Like this item"></i></label>
</a>
<div class="UIImageBlock_Content UIImageBlock_ICON_Content">Syed Murtaza Zaidi likes this.</div>
</div>
</li>
<li class="uiUfiComments uiListItem uiListVerticalItemBorder hidden_elem">
<ul class="commentList">
</ul>
</li>
<li class="uiUfiAddComment clearfix ufiItem ufiItem uiListItem uiListVerticalItemBorder uiUfiAddCommentCollapsed">
<div><img class="uiProfilePhoto actorPic UIImageBlock_Image UIImageBlock_ICON_Image uiProfilePhotoMedium img" src="http://profile.ak.fbcdn.net/hprofile-ak-snc4/41709_1014341698_4889488_q.jpg" alt="">
<div class="commentArea UIImageBlock_Content UIImageBlock_ICON_Content">
<div class="commentBox">
<textarea class="DOMControl_placeholder uiTextareaNoResize uiTextareaAutogrow textBox textBoxContainer" title="Write a comment..." placeholder="Write a comment..." name="add_comment_text" onfocus="return wait_for_load(this, event, function() {if (!this._has_control) {new TextAreaControl(this).setAutogrow(true);this._has_control = true;}});">Write a comment...</textarea>
</div>
<label class="mts mts commentBtn stat_elem optimistic_submit uiButton uiButtonConfirm" for="u127419_35">
<input value="Comment" name="comment" id="u127419_35" type="submit">
</label>
</div>
</div>
</li>
</ul>
<input value="{"src":10,"sty":263,"actrs":"514782389","object_id":184361748268334,"pub_time":1298066944,"fbid":"184361748268334","qid":"5575216616647978849","mf_objid":184361748268334,"s_obj":5,"s_edge":1,"s_prnt":3,"pos":9,"filter":"h"}" name="link_data" type="hidden">
</form>
Because
BUTTON type="submit" and INPUT type="submit" are the standard way to submit forms
Like-action uses a POST-request because POST-requests should be used when some server-side state is altered.
Like-action contains several parameters with long values. Some browsers have a limit to URL length and the parameters of the like-action might exceed that length if it was sent as a GET-request.
Using standard elements allows all browsers to submit like-action correctly as a POST-request even without javascript. Using links would result in a GET-request.
I never noticed that it was a button and not a link, nice catch.
It's likely because the "Like" action isn't a true link. It doesn't take you anywhere. So while they styled it like a link, it isn't actually a link. They could have used a link, sure, but I think using the button is a bit more correct. Clicking a button performs an action, as opposed to a link which takes you to a new page. That matches well with what happens when you "like" something on facebook.
Even the mobile version seems to use links. The button must be a remnant from the time they thought they needed to support more restrictive browser settings. – Aleksi