Change to type password onblur - html

I try to do a form with the information in the same input. It works fine in all the inputs but in the password it would be better if it could change to points when the user introduces the password. I want it to be type text and change to type password ONLY when the user introduces the password. The problem is in the last line of code:
I have it life here: http://jsfiddle.net/Nt9gx/
<form>
<input type="text" name="name" value="name"
onfocus="if (this.value=='name') this.value = '';"
onblur="if (this.value=='') this.value = 'name';"
/>
<input type="text" name="password" value="password"
onfocus="if (this.value=='password') this.value = '' type = password;"
onblur="if (this.value=='') this.value = 'password';"
"if (this.value!=''|| 'password') type = password ;"
/>
</form>

Use the HTML5 placeholder
To get the job done, you should simply use the HTML5 placeholder-attribute, like this:
<input type="password" name="password" placeholder="Password">
As this will:
show the placeholder, while no text is inserted or if all text is removed again
it shows the text even on a password field
no need using JavaScript
By the way:
you used two times onblur on the last input, this should occur only once
the last line is syntactically wrong, as you need to escape the word password in ' (single quotes) instead of " (double quotes) (question was updated)
the last line uses an undefined variable called password in || password)
use type="password" for input fields that handle, well, passwords, as the input will be "invisible"
Note:
If you still want to use JavaScript, you have to change the input from type="text" to type="password" within the focus and blur events by simply updating the type-attribute.
This is how you can do it:
<input type="text" name="password" value="password"
onfocus="if (this.value == 'password') { this.value = '', this.setAttribute('type','password'); }"
onblur="if (this.value == '') { this.value = 'password', this.setAttribute('type','text'); }"
>
Demo: http://jsfiddle.net/2Ps8N/​

<input type="text" name="name" value="name"
onfocus="if (this.value=='name') this.value = '';"
onblur="if (this.value=='') this.value = 'name';"
/>
<input type="password" name="password" value="password"
onfocus="if (this.value=='password') this.value = '';"
onblur="if (this.value=='') this.value = 'password';"
onblur="if (this.value!=''|| password) value = 'password';"
/>
you entered a double quote!

You can change the password input like this :
<input type="text" name="password" value="password" type="password"
onfocus="if (this.value=='password') this.value = '';"
onblur="if (this.value=='') this.value = 'password';"
/>
Yoc can add more conditions in if (this.value=='') but do it just in this onblur and do not write another onblur
You have this.value = "password" in the last line which is wrong and you must use 'password' instead of "password"
in the last if condition you have the parameter password that is not defined before using it. you should define var password before this if or you should change this condition

Related

Specify input for password manager autofill

I have a form with multiple inputs, but when autofilling, the password manager always enters data in the first input above the password. Can I tell it to enter data in a specific input?
Code example:
<input placeholder="Your email" type="email"/>
<input placeholder="You fb id" type="text" />
<input placeholder="Your password" type="password"/>
Chrome might think that your email and text inputs are the same, so it auto fills both of them. So, we are going to put an irrelevant "type" on one of the inputs.
<input placeholder="Your email" type="email"/>
<input placeholder="You fb id" type="url" />
<input placeholder="Your password" type="password"/>
We set the email type to email, fb id to url, and password type to password.
Finally found a solution!!!! If you add an onChange event to the field that is above the password field and accepts automatic login fill, it will fill data in the field specified in js. Here is code example:
HTML:
<input placeholder="Your email" id="userEmail" type="email" />
<input placeholder="You fb id" id="fbId" type="text" />
<input placeholder="Your password" type="password" />
JS:
const fbId = document.querySelector("#fbId");
fbId.onChange = () => {
document.querySelector("#userEmail").value = fbId.value;
};
Result:

Why won't this code display on a wordpress page?

This code displays as plain text on any pages I put it on. It is supposed to display two text boxes and two buttons
<div onmouseover="change_background(this, '#FCF6CF')" onmouseout="change_background(this,'#E8E8E8')" id="client_portal_content">
Client Login
<INPUT id=logintext size="15" onblur="if (this.value == '')
this.value='Your client ID'" onfocus="this.value=''" value="Your client
ID"></INPUT>
<INPUT id=loginbutton onclick="if
(document.getElementById('logintext').value != 'Your client ID')
window.open('http://1010.cmmcloud.com/progress/progress.php?id=p-'+document.getElementById('logintext').value)" type=button value=Login></INPUT>
<br><br> Affiliate Login
<INPUT id=logintextaff size="15" onblur="if
(this.value == '') this.value='Your affiliate ID'" onfocus="this.value=''" value="Your affiliate ID"></INPUT>
<INPUT id=loginbuttonaff onclick="if
(document.getElementById('logintextaff').value != 'Your affiliate ID')
window.open('http://1010.cmmcloud.com/affportal/portal.php?id=a-'+document.getElementById('logintextaff').value)" type=button value=Login></INPUT>
</div>
You have errors in your code, which doesn't explain why it appears as plain text, but would explain why it won't run in any case. Instead of using a function 'onblur' to fill the text and then check if it's filled on submit, use placeholder text, and then check if the input is empty.
See below example:
function check() {
var x = document.getElementById("#myid");
if (x == null|| x=="") {
alert("Fill in your id!");
}
}
<input id="myid" type="text" placeholder="Client ID" />
<button onclick="check();">Click me</button>
Hope this helps
EDIT:
In your tag (which doesn't need to be capitalised, by-the-by), you have
onclick="if
(document.getElementById('logintext').value != 'Your client ID'
Replace with
onclick="if
(document.getElementById('logintext').value != null )
<input id="logintext" size="15" placeholder ="Your Client ID"
value=" "></input>

Sending an email from HTML [duplicate]

This question already has answers here:
Can I set subject/content of email using mailto:?
(13 answers)
Closed 7 years ago.
<form action="MAILTO:myemail#example.com" method="post" enctype="text/plain">
<input type="text" value="Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name';}" required="">
<input type="text" value="E-mail" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'E-mail';}" required="">
<textarea type="text" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}" required="">Message</textarea>
<input type="submit" value="SEND">
</form>
The code above is in my HTML file. Once I write text in the textboxes and click the submit button it opens a new email using my email client (So far so good). But, there is not any content in the body of the email. I want to have the text I inputted to be in the body of the new email which just opened. I do not want to use any PHP or JavaScript files. I want everything to be in the HTML file.
Thanks!
Add name=body to your text area
<textarea name='body' ... ></textarea>
Each of the other inputs can be assigned to the different lines of the email message (ie, the subject line, to line, cc, etc). All you need to do is set the "name" property of each input to the line of the email you want it to appear.
If you want your name input to be the subject of the message, add `name='subject' to your name input.
https://en.wikipedia.org/wiki/Mailto
Also, you should probably change the method to 'GET' and enforce a URI encode before the data is sent using encodeURI(value of the textarea)

Use text of text form for value of another?

I am fairly new to HTML and am having trouble figuring out this issue.
I have this form which lets the user enter their email address and then when they submit it registers them to the website.
I am wondering how can I get the value of the email address they enter for the value of another form?
Here's what I am working with. Any tips?:
<form class="form" method="post" action="https://register.sendreach.com/forms/?listid=7465"><input name="lid" value="7465" type="hidden">
<div class="field"><label>Email:</label>
<input class="text" name="email" value="My best email address is..." onblur="if (this.value == '') {this.value = 'My best email address is...';}" onfocus="if (this.value == 'My best email address is...') {this.value = '';}" type="text">
<form action="http://mywebsite.com/?mode=register&type=quick" method="post">
<input type="text" name="member_email" value = /></p> **<--- Here is where I want to get the email address text used earlier in the name field called email and use it for the name field member_email. I want to use that as the value. How do I grab that?**
<input name="product_id" value="1" type="hidden">
<input name="success_url" value="aHR0cDovL2luY29tZWphY2tlci5jb20vbWVtYmVyc2hpcC1ob21lLw==" type="hidden"></div>
<input class="button small_btn" value="Get Instant Access" type="submit">
<p class="small">Download Sent To Email!</p>
</form>
Do something on submit (similar to how you're doing something on focus and on blur):
<form onsubmit="...
On the submit event, get the two email inputs:
var sourceInput = document.getElementsByName('email')[0];
var targetInput = document.getElementsByName('member_email')[0];
...and set the value:
targetInput.value = sourceInput.value;
I didn't test the above, but I believe that should do what you're looking for. It may be better to give the two inputs ids as well, so you can use getElementById instead of getElementsByName.
Edit:
The above would only work if both inputs and forms are on the same page, and also if the page is not refreshed. Based on the question, I am assuming that's the case. The above also does not check to see if the email was saved successfully (again, I don't know if that's something you want to check before copying the email over).
use sessions
page one:
<?php
session_start();
$_SESSION['email_address']=$email_variable;
?>
page two:
<php
new_email_variable=$_SESSION['email_address'];
?>
use this.
<form class="form" method="post" action="https://register.sendreach.com/forms/?listid=7465"><input name="lid" value="7465" type="hidden">
<div class="field"><label>Email:</label>
<input class="text" name="email" value="My best email address is..." onblur="if (this.value == '') {this.value = 'My best email address is...';} document.getElementById('member_email').value=this.value;" onfocus="if (this.value == 'My best email address is...') {this.value = '';}" type="text">
<form action="http://mywebsite.com/?mode=register&type=quick" method="post">
<input type="text" name="member_email" id="member_email"></p> **<--- Here is where I want to get the email address text used earlier in the name field called email and use it for the name field member_email. I want to use that as the value. How do I grab that?**
<input name="product_id" value="1" type="hidden">
<input name="success_url" value="aHR0cDovL2luY29tZWphY2tlci5jb20vbWVtYmVyc2hpcC1ob21lLw==" type="hidden"></div>
<input class="button small_btn" value="Get Instant Access" type="submit">
<p class="small">Download Sent To Email!</p>
</form>
notice i have added id attribute to the input tage where you want to get the email address. and a little code in the tag from where you want to get the email address

How to make the type of input password when the user actually selects the input box?

This is the code I have already. When the box is inactive it displays the text"Password". I would like when the box is selected it removes the "Password" text and displays the users input as dots like a password field.
<div class="custom"><input type="text" class="custom" size="12" value="Password" onfocus="if(this.value == 'Password') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Password'; }"/></div>
You can change the type via JS the same way you've changed the value:
<input type="text" class="custom" size="12" value="Password" onfocus="if(this.value == 'Password') { this.type = 'password'; this.value = ''; }" onblur="if(this.value == '') { this.type = 'text'; this.value = 'Password'; }"/>
If i understand correctly, you're just looking for:
this.type = 'password'
and conversely:
this.type = 'text'
You should start by setting the type of the input to 'password'. If you want to display a label for the field in the value, i would recommend using the JQuery watermark. It effectively does what i believe you are attempting to code out, but won't ever submit the word 'Password' as the value of the form field.