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

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>

Related

Submit HTML login form with Enter key?

I have been going through many solutions to my issues with other older questions, but I can't seem to implement any of the solutions.
I am trying to create a simple login box using a form, which then loads a particular webpage based on the login info. This is what I currently have;
<div class="container">
<form name="login">
<p class="paragraph">Username <input class="login" type="text" placeholder="Enter Username" name="userid"/></p>
<p class="paragraph">Password <input class="login" type="password" placeholder="Enter Password" name="pswrd"/></p>
<p class="paragraph"><input type="button" onclick="check(this.form)" value="Login"/></p>
</form>
function check(form)
{
if(form.userid.value == "pf900" && form.pswrd.value == "password")
{
window.open('/pf900_pid/index.htm','_self')
}
else if(form.userid.value == "pf350a" && form.pswrd.value == "password")
{
window.open('/pf350a_pid/index.htm','_self')
}
else
{
alert("Error: Wrong username or password")
}
}
My issue is, that I can't seem to work the form so that the enter key will activate the login button. If I change the button to a submit, it just puts the login info in the address bar and doesn't perform the correct action.
I'm going to summarize what everyone has said here and put it in a single answer.
On the <form> element, be sure to use the onSubmit
Change the input type to submit
Remove the click handle on the <input>
function check() {
event.preventDefault();
var form = document.forms["login"];
if (form.userid.value == "pf900" && form.pswrd.value == "password") {
window.open('/pf900_pid/index.htm', '_self')
} else if (form.userid.value == "pf350a" && form.pswrd.value == "password") {
window.open('/pf350a_pid/index.htm', '_self')
} else {
alert("Error: Wrong username or password")
}
}
<div class="container">
<form name="login" onSubmit="check()">
<p class="paragraph">Username <input class="login" type="text" placeholder="Enter Username" name="userid" /></p>
<p class="paragraph">Password <input class="login" type="password" placeholder="Enter Password" name="pswrd" /></p>
<p class="paragraph"><input type="submit" value="Login" /></p>
</form>
</div>
Keep the input type as "Submit:
<input type="submit"/>
and on the Check function, use
event.preventDefault();
please switch your code to this one:
form method="post" onsubmit="check(this.form)" action="place your
function here"
input type="submit" value="Login"/>
button won't work on form element, it is rather use in dom events or showing a modal.
Hope this helps!
We can do in two different ways, just change the input type to submit or add onkeypress event check the enter key like below.
<div class="container">
<form name="login" onkeypress="onEnter(event)">
<p class="paragraph">Username <input class="login" type="text" placeholder="Enter Username" name="userid"/></p>
<p class="paragraph">Password <input class="login" type="password" placeholder="Enter Password" name="pswrd"/></p>
<p class="paragraph"><input type="submit" onclick="check(this.form)" value="Login"/></p>
</form>
onkeypress function block
function onEnter(e){
if(e.keyCode == 13)
check()
}

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)

Why wont <button type="submit"> work?

I have a standard HTML form, and the button is not working. I know it is directing to the correct page, and as far as I can see everything looks perfect.
It lets me click the button, but then nothing happens, it doesn't direct me to the send.php page or anything.
<form method="post" action="http://www.URL.net/send.php">
<p>
<label for="name">Name <span class="required">*</span></label>
<input type="text" name="name" id="name">
</p>
<p>
<label for="email">Email <span class="required">*</span></label>
<input type="text" name="email" id="email">
</p>
<p>
<label for="subject">Subject</label>
<input type="text" name="subject" id="subject">
</p>
<p>
<label for="subject">Message <span class="required">*</span></label>
<textarea name="message" id="message" cols="45" rows="10"></textarea>
</p>
<div class="fBtn">
<button type="submit" name="submit" id="submit" class="regButton"><i class="icon-paper-plane"></i>Send Message</button>
</div>
</form>
Also, I have tried using <input type="submit" name="submit" id="submit" class="regButton" value="Send Message" /> as well, but it also isn't working for some odd reason.
Tested in Chrome and IE11.
EDIT Here is the JS for form vaildation:
$('#submit').click(function(){
$('input#name').removeClass("errorForm");
$('textarea#message').removeClass("errorForm");
$('input#email').removeClass("errorForm");
var error = false;
var name = $('input#name').val();
if(name == "" || name == " ") {
error = true;
$('input#name').addClass("errorForm");
}
var msg = $('textarea#message').val();
if(msg == "" || msg == " ") {
error = true;
$('textarea#message').addClass("errorForm");
}
var email_compare = /^[a-zA-Z0-9._-]+#[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i;
var email = $('input#email').val();
if (email == "" || email == " ") {
$('input#email').addClass("errorForm");
error = true;
}else if (!email_compare.test(email)) {
$('input#email').addClass("errorForm");
error = true;
}
if(error == true) {
return false;
}
var data_string = $('.contactForm form').serialize();
$.ajax({
type: "POST",
url: $('.contactForm form').attr('action'),
data: data_string,
success: function(message) {
if(message == 'SENDING'){
$('#success').fadeIn('slow');
}
else{
$('#error').fadeIn('slow');
}
}
});
return false;
});
You appear to have some JavaScript that automatically submits every form using AJAX. Since you’re on the domain trishajohnson.net, the same-origin policy prevents JavaScript from opening requests to a (slightly) different domain – www.trishajohnson.net.
There’s an easy fix, though – just use the path part. It’s cleaner anyway.
<form method="POST" action="/tj/send.php">

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 do I make my Search Field show some text and make it disappear when it's clicked

I want my search field to say "Where are you" make it disappear when clicked and and appear again when if he clicks outside leaving it blank.
This is the search form:
<div id="search-10" class="widget_search">
<form role="search" method="get" id="searchform" action="http://chusmix.com/?s=" onsubmit="window.location = action + s.value + '+: <?php the_search_query() ?>'; return false;">
<div>
<input class="ubicacion" type="text" value="" name="s" id="s2" style="margin-left:0px;">
<input type="submit" id="searchsubmit" value="Buscar">
</div>
</form></div>
I tried this but for some reason it didn't work:
<li id="search-10" class="widget_search">
<form role="search" method="get" id="searchform" action="http://chusmix.com/">
<div>
<input class="ubicacion" type="text" value="" name="s" id="s" style="margin-left:418px;">
<input type="submit" id="searchsubmit" value="Buscar" onblur=" if(this.value== '') this.value='Where are you';" onfocus=" if(this.value=='Where are you') this.value=''; " value="Where are you" name="keyword" />
</div>
</form></li>
This removes the default text when a user clicks on the search form and adds it back when the user clicks off the search form.
<form id="searchform" method="get" action="search.php">
<input class="textbox" value="Search" name="s" id="s" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" type="text">
<input type="submit" id="searchsubmit" value="" class="searchsubmit" />
</form>
Fake the border of the input using a div, and position the real input and a label inside it - one of top of the other.
Conceal the label when the element gets the focus, put it back when the focus is lost if the value is blank.
There is an example using jQuery.
See the example below for raw javascript -
<input type="text" onblur=" if(this.value== '') this.value='Where are you';" onfocus=" if(this.value=='Where are you') this.value=''; " value="Where are you" name="keyword" />
Beside this, you can use jquery, dojo, mootools plugin to handle this.