iOS 7 weird button on a html submit input - javascript

Im building an HTML5 Phonegap app for iOS. This submit button is a normal html input submit like this:
<input type="text" autocorrect="off" autocapitalize="off" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
<input class="signin" type="submit" value="Sign in">
.signin {
padding: inherit;
background: #006ad9;
width: 243px;
height: 50px;
border: 0px;
margin-top: 3px;
color: #fff;
font-size: 1.2em;
}
This si how it looks on the iOS similator:
Even those input text's are rounded, my CSS has no such style for it!
Why is this happening?

Try
input[type=submit] {
-webkit-appearance: none;
border-radius: 0;
}
Put this at the top of the css and then set styles for your classes

Related

How to sync typing between a span and an input?

I'm making a new I found way to sync typing between a span and an input ("https://stackoverflow.com/questions/8803416/synchonise-2-input-fields-can-it-be-done-using-jquery") and it works but I've come across a problem.
What I'm trying to do is create a multi-line title in WordPress using the classic editor and the input requires any text entered to be set in value="". It looks like this below:
<input type="text" name="post_title" size="30" value="" id="title" spellcheck="true" autocomplete="off">
So how do I sync typing between a span and an input but text is in value=""?
This is the code I've done so far (yes the code works, look at it in debug mode and you'll see the text showing up at the end of the input):
$("<span class='titlebox' role='textbox' contenteditable='true'></span>").insertAfter("#title");
$("span.titlebox").bind("keyup paste", function() {
$("input#title").text($(this).text());
});
.titlebox {
ont-size: 2.7em;
letter-spacing: -0.5px;
font-weight: 600;
display: block;
width: 100%;
overflow: hidden;
resize: none;
word-wrap: break-word;
border: 1px solid #000
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="post_title" size="30" value="" id="title" spellcheck="true" autocomplete="off">
$("input#title").text() never works. Instead you need to use $("input#title").val() to fill it.
$("<span class='titlebox' role='textbox' contenteditable='true'></span>").insertAfter("#title");
$("span.titlebox").on("input", function() {
$("input#title").val($(this).text());
});
.titlebox {
ont-size: 2.7em;
letter-spacing: -0.5px;
font-weight: 600;
display: block;
width: 100%;
overflow: hidden;
resize: none;
word-wrap: break-word;
border: 1px solid #000
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="post_title" size="30" value="" id="title" spellcheck="true" autocomplete="off">

Form Element Resizing After Submission

I am working on a system that makes use of a form to enter some data into a database. The system works as expected except for an issue with the display of the form after it has been submitted. When the form is submitted the page reloads and will show the info submitted as placeholder text inside of the form fields, and the "Save Changes" button will display as "Changes Saved!" for a few seconds. However, some of the input fields width property gets altered as well. Specifically my half-width form elements.
The width for these elements is defined as width: calc(50% - 24px), which is 265px. Additionally, there is a 5px padding and 2px border for these elements. This comes out to a total width of 279px, as expected. However, when the form is submitted and the page is reloaded the total width of the element comes out as 265px, retaining the 5px padding and 2px border, but dropping the internal width to 251px. Nowhere in my code is there anything that changes the width ever, and checking with dev tools shows that the width, padding, and border I defined are still there. This has the rather annoying effect of shifting both elements over after the form is submitted. Navigating to another page and back resolves the issue.
I have tried using !important and have checked over all of the code (JavaScript) echoed out from PHP when the submission is successful that interacts with the form in a capacity for changing things, and nothing should have this impact. I only change the color and text of the submit button.
Any help would be greatly appreciated!
Edit 1:
The code below is a snippet of the entire form, excluding the PHP. I have modified the code so that clicking save changes does not submit the form but will show the change for the submit button, as otherwise submitting makes the form vanish. The error does not occur in the snippet of code however as a result of not "reloading" the page.
function success() {
var button = document.getElementById('clientInfoBtn');
var normalColor = button.style.backgroundColor;
var normalValue = button.value;
button.style.backgroundColor = '#33cc33';
button.value = 'Changes Saved!';
setTimeout(function() {
button.style.backgroundColor = normalColor;
button.value = normalValue;
}, 3000);
return false;
}
.standardFormBox {
margin-bottom: 20px;
width: 600px;
}
.standardFormBoxInner {
border: 1px solid silver;
padding: 10px;
display: flex;
flex-wrap: wrap;
}
.standardFormHeading {
font-family: "Helvetica";
font-size: 16pt;
color: white;
background-color: #1975FF;
margin: 0;
padding: 10px;
}
.standardFormBtn {
color: white;
font-size: 14pt;
background-color: #1975FF;
border: none;
padding: 10px 10px;
margin-bottom: 15px;
}
.standardFormBtn:hover {
cursor: pointer;
background-color: #0052cc;
}
.standardFormInput {
font-size: 14pt;
font-family: "Trebuchet MS";
margin-bottom: 10px;
padding: 5px;
}
.sfiMultiLabel {
font-size: 14pt;
font-family: "Trebuchet MS";
}
.sfiHalf {
width: calc(50% - 24px);
}
.sfiText {
font-size: 14pt;
margin: 0;
}
.sfiTextHalf {
width: calc(50% - 10px);
}
.sfiTextFull {
width: 100%;
}
.sfiFull {
width: 100%;
}
.sfiLeft {
margin-right: 20px;
}
<form name="accountInfoForm" method="POST">
<div class="standardFormBox">
<p class="standardFormHeading">Business Billing Information</p>
<div class="standardFormBoxInner">
<p class="sfiText sfiTextHalf">Business Name</p>
<input type="text" name="cBusiness" placeholder="" class="standardFormInput sfiFull">
<p class="sfiText sfiTextHalf">Name On Bank Account</p>
<input type="text" name="cName" placeholder="" class="standardFormInput sfiFull">
<p class="sfiText sfiTextHalf">Billing Email</p>
<input type="email" name="cEmail" placeholder="" class="standardFormInput sfiFull">
<p class="sfiText sfiTextHalf">Street Address</p>
<input type="text" name="cStreet" placeholder="" class="standardFormInput sfiFull">
<p class="sfiText sfiTextHalf">City</p>
<input type="text" name="cCity" placeholder="" class="standardFormInput sfiFull">
<p class="sfiText sfiLeft sfiTextHalf">State</p>
<p class="sfiText sfiTextHalf">ZIP</p>
<input type="text" name="cState" placeholder="" class="standardFormInput sfiLeft sfiHalf">
<input type="text" name="cZip" placeholder="" class="standardFormInput sfiHalf">
<p class="sfiText sfiTextHalf">Phone Number</p>
<input type="text" name="cPhone" placeholder="" class="standardFormInput sfiFull">
</div>
</div>
<input type="submit" name="clientChangeInfo" value="Save Changes" class="standardFormBtn" id="clientInfoBtn" onclick="return success()">
</form>

How can I make the website remember last shown form?

I have two forms inside one div:
Login form
Register form
Register form is hidden while login form is shown as default when you load the page. Im using js script to animate between those two forms by clicking anchor tag.
This causes problems for example while trying to register and you don't go through validation process correctly.
Hypothetical situation:
You've filled all the inputs, click submit button and it turns out that username you've provided is too short. The page will reload and it will show the default form again which is login form. You then again need to click "Register" a tag in order to switch between forms and then you see the error with validation.
I've been trying to read up about ways of doing that for days but seems like I can't specify my problem well enough in a short phrase. Can you guys explain what kind of method should I use and explain how to use it?
HTML:
<div class="login-page">
<div class="form">
<form class="register-form" method="POST">
<input type="text" name="nick" placeholder="username"/>
<input type="password" name="password1" placeholder="password"/>
<input type="password" name="repassword" placeholder="repeat password"/>
<input type="text" name="email" placeholder="e-mail adress"/>
<button>Create</button>
<p class="message">Already have an account? Log in!</p>
</form>
<form class="login-form" method="POST" action="login.php">
<input type="text" name="login" placeholder="username"/>
<input type="password" name="password" placeholder="password"/>
<button>log in</button>
<p class="message">Don't have an account yet? <a id="createacc" href="#">Sign up!</a></p>
</form>
JS:
$('.message a').click(function(){
$('form').animate({height: "toggle", opacity: "toggle"}, "slow"});
I want the website to remember which form you were filling before the page reloaded instead of always showing the default one (which is login form).
EDIT: In case anyone wondering. Yes, I did create similiar post about this yesterday but I realised that I didn't explain this well enough. Hope this goes through well.
You could make use of sessionStorage, a similar mechanism to cookies that persist only for the current session. When switching the visibility of your forms, set accordingly which one is also shown:
window.sessionStorage.setItem('lastOpenedForm', 'register');
And once the page loads again, fetch the value from there and display that form:
window.sessionStorage.getItem('lastOpenedForm');
Adapted code in snippet below:
var lastOpenedForm = window.sessionStorage.getItem("lastOpenedForm");
// By default show login form; check if we should show register and toggle visibilities
if (lastOpenedForm === "register-form") {
console.log('last opened form was register form');
$(".form form").toggleClass("active-form");
$(".login-page").toggleClass("bigger");
}
$(".message a").click(function() {
$(".form form").toggleClass("active-form");
var activeForm = $('.active-form').eq(0).attr('id');
window.sessionStorage.setItem('lastOpenedForm', activeForm);
console.log('last active form is ' + activeForm);
$(".login-page").toggleClass("bigger");
});
// $("#createacc").click(function() {
// window.sessionStorage.setItem("lastOpenedForm", "register-form");
// });
.login-page {
width: 600px;
height: 290px;
background: #333333;
border-radius: 50px;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.5), 0 10px 10px 0 rgba(0, 0, 0, 0.24);
transition: all 1s;
}
.login-page.bigger {
height: 420px;
}
.form {
position: relative;
max-width: 360px;
margin: auto;
padding: 45px;
text-align: center;
}
.form input {
font-family: "Roboto", sans-serif;
outline: 0;
background: #f2f2f2;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 14px;
border-radius: 5px;
}
.form button {
font-family: "Roboto", sans-serif;
text-transform: uppercase;
outline: 0;
background: #666666;
width: 100%;
border: 0;
padding: 15px;
color: #FFFFFF;
font-size: 14px;
cursor: pointer;
border-radius: 5px;
}
.form button:hover,
.form button:active,
.form button:focus {
background: #808080;
}
.form .message {
margin: 15px 0 0;
color: white;
font-size: 16px;
}
.form .message a {
color: #1a8cff;
text-decoration: none;
}
.form form {
/* display: none; */
visibility: hidden;
opacity: 0;
height: 0;
transition: 0.5s easy-in-out all;
}
.form .active-form {
visibility: visible;
opacity: 1;
height: auto;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div class="login-page">
<div class="form">
<form id="register-form" method="POST">
<input type="text" name="nick" placeholder="username" />
<input type="password" name="password1" placeholder="password" />
<input type="password" name="repassword" placeholder="repeat password" />
<input type="text" name="email" placeholder="e-mail adress" />
<button>Create</button>
<p class="message">Already have an account? Log in!</p>
</form>
<form id="login-form" method="POST" class="active-form" action="login.php">
<input type="text" name="login" placeholder="username" />
<input type="password" name="password" placeholder="password" />
<button>log in</button>
<p class="message">Don't have an account yet? <a id="createacc" href="#">Sign up!</a></p>
</form>
</div>
Also available in this codepen.
If you're relying on JavaScript then you have a few possible routes.
Use localStorage to set and get the state. https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
Use a cookie to set and get the state. https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
Use a query string parameter as part of your url and use the Location api to get it. https://developer.mozilla.org/en-US/docs/Web/API/Location
Javascript has no way of remembering state so you must make use of a strategy such as the above. Personally I would opt for localStorage as it has a nice simple API.
You can use localStorage to store the state in your browser.
<div class="login-page">
<div class="form">
<form class="register-form" method="POST" id="register">
<input type="text" name="nick" placeholder="username"/>
<input type="password" name="password1" placeholder="password"/>
<input type="password" name="repassword" placeholder="repeat password"/>
<input type="text" name="email" placeholder="e-mail adress"/>
<button>Create</button>
<p class="message">Already have an account? Log in!</p>
</form>
<form class="login-form" method="POST" action="login.php" id="login">
<input type="text" name="login" placeholder="username"/>
<input type="password" name="password" placeholder="password"/>
<button>log in</button>
<p class="message">Don't have an account yet? <a id="createacc" href="#">Sign up!</a></p>
</form>
var fo;
$(document).ready(function(){
console.log(localStorage.getItem('form'))
$('form').click(function(){fo=$(this).attr('id');
localStorage.setItem('form',fo);
})
})
Working fiddle
You might consider using a URL fragment at the end of your form action attribute--e.g. <form action="example.com/#register">.
URL fragments are typically used to jump to different sections on a page. So in this case, they're probably more semantically meaningful than other options like session storage, cookies, or query strings.
You just need to listen to the document's load event to determine which form is being targeted. Something like this:
$(function () {
if (window.location.hash == "register") {
// show registration form here
}
});

How do I make a html input have static characters (input mask) that stay when the user types? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to make an input field on my website have a placeholder like this (note: the black characters are static input masks):
And if the user types into the input box it should look like this (note: the user did not have to type the mask characters):
When I tried to use the placeholder attribute the text disappear after the user types - which isn't what I want. It would be much better if there was a special syntax like yyyy/mm/dd hh:mm and the user was just able to write between the double dot (colon) and slashes.
I have no idea how to build something like this, and even Google doesn't understand what I'm trying to say.
EDIT:
The feature I am trying to implement is called Input Masks.
If you're using jQuery for your project, this should be fairly easy to implement.
As David Thomas said in a comment on your original question, you need to used masked input. There's a great plugin for this (if you're using jQuery) that's really easy to implement, well documented and more or less does exactly what you want to do:
http://igorescobar.github.io/jQuery-Mask-Plugin/
There are three methods that I know of, but none are really practical.
Wrap a label around the input and add ::before content
<label><input type="text" /></label>
label { position: relative; }
label::before {
position: absolute;
top: 0;
z-index: 1;
color: red;
font-family: monospace;
content: "\00a0\00a0\00a0\00a0/\00a0\00a0/\00a0\00a0\00a0:";
}
Use multiple inputs, and make them appear as one
<div id="wrapper">
<input class="x" type="text" maxlength="4" placeholder="YYYY" />/<!--
--><input class="x" type="text" maxlength="2" placeholder="MM" />/<!--
--><input class="x" type="text" maxlength="2" placeholder="DD" />,<!--
--><input class="x" type="text" maxlength="2" placeholder="hh" />:<!--
--><input class="x" type="text" maxlength="2" placeholder="mm" />
</div>
#wrapper { display: inline-block; background-color: #FFF; border: 1px solid #000; }
.x { border: none; }
.x:first-of-type { width: 4em; }
.x:not(:first-of-type) { width: 2em; }
Use another "readonly" and pointer-events:none absolutely positioned input
<div id="wrapper2">
<input type="text" />
<input id="over" type="text" readonly value="YYYY/MM/DD hh:mm" />
</div>
#wrapper2 { position: relative; display: inline-block; }
#over { position: absolute; top: 0; pointer-events: none; background: none; opacity: 0.5; }
label { position: relative; }
label::before {
position: absolute;
top: 0;
z-index: 1;
color: red;
font-family: monospace;
content: "\00a0\00a0\00a0\00a0/\00a0\00a0/\00a0\00a0\00a0:";
}
#wrapper { display: inline-block; background-color: #FFF; border: 1px solid #000; }
.x { border: none; }
.x:first-of-type { width: 4em; }
.x:not(:first-of-type) { width: 2em; }
#wrapper2 { position: relative; display: inline-block; }
#over { position: absolute; top: 0; pointer-events: none; background: none; opacity: 0.5; }
<label><input type="text" /></label>
<div id="wrapper">
<input class="x" type="text" maxlength="4" placeholder="YYYY" />/<!--
--><input class="x" type="text" maxlength="2" placeholder="MM" />/<!--
--><input class="x" type="text" maxlength="2" placeholder="DD" />,<!--
--><input class="x" type="text" maxlength="2" placeholder="hh" />:<!--
--><input class="x" type="text" maxlength="2" placeholder="mm" />
</div>
<div id="wrapper2">
<input type="text" />
<input id="over" type="text" readonly value="YYYY/MM/DD hh:mm" />
</div>

Only last Input works

I have this huge form I'm making and there's an also huge problem with it.
In some "areas". only the last input works.
For example here:
[...]
<div class="main_data">
<span class="info">main data</span><br>
<input type="text" name="name" placeholder="Name" required>
<input type="email" name="email" placeholder="Email" required>
<input type="text" name="website" placeholder="Website" required>
<input type="text" name="telephone" placeholder="Telephone" required>
<input type="text" name="address" placeholder="Address" required>
<input type="text" name="city" placeholder="City" required>
<input type="text" name="country" placeholder="Country" required>
</div>
[...]
Every input appears to be disabled(?) and I can only write on Country.
This also happens on some other areas of the form, for example here:
[...]
<div class="detailed_info">
<span class="info">detailed info</span>
<input type="text" name="activity_areas" placeholder="Activity Areas" required>
<input type="text" name="company_valences" placeholder="Description of Company Valences" required>
<input type="text" name="where_operates" placeholder="Markets / Countries where it operates" required>
<input type="text" name="where_operates" placeholder="Annual Turnover (Value EUR)" required>
[...]
I can only write on Annual Turnover.
I tried switching z-index's to check out if it was something over it but I didn't find anything wrong.
I'll paste the css of only the first part, I belive if I find what's happening on the first one I'll be able to correct the second.
.main_data{
width: 100%;
padding: 30px 0;
background: rgba(238, 238, 238, 0.9);
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
text-align: center;
}
.main_data .info{
display: block;
width: 100%;
margin: 0 0 10px 0;
font-size: 20px;
font-family: 'Futura-Light-Italic', sans-serif;
}
.main_data input{
border: 0;
padding: 5px 0;
margin: 0;
width: 80%;
background: #FFF;
color: #000;
text-align: center;
font-family: 'Futura', sans-serif;
}
.main_data input:focus{
border: 0;
}
I'm still afraid that it might not have nothing to do with the form so I'll leave you guys a link to the page so can try inspecting some elements if you want.
To bring up the form you click Join the City as One of Us: link
I'm really needing help as this form must be ready today.
Please ask questions if you don't understand something! I will obviously try to help you helping me.
EDIT: I'm using Google Chrome
Change the line-height on .oneofus.
.oneofus {
width: 88%;
position: absolute;
z-index: 12;
top: 0;
line-height: 1px; /* this is the problem remove it or make it bigger (74px or more) */
}
Set the position of the inputs to relative..
.main_data input {
position: relative;
}

Categories

Resources