JavaScript, ajax Auto - Login - javascript

What is wrong http://jsfiddle.net/qch1vtqc/
I'm trying to create an Automatic Log On another web page , without leaving the current page , beer somehow I have not succeeded.
<form id="loginForm" name="loginForm" method="post"
action="http://www.streamuj.tv/login">
<p>
<label for="name">Uživatel:</label>
<br>
<input type="text" name="username" value="examplename" size="22"
tabindex="3" id="name" class="logintext">
<br>
<label for="password">Heslo:</label>
<br>
<input name="password" type="password" value="exampepass"
class="logintext" id="password" tabindex="4" size="22">
<br>
<a href="http://www.streamuj.tv/recoverpassword"
title="Forgot!">Zapomněli jste heslo?</a><br>
<input type="hidden" name="action_login" value="Přihlásit se">
<input type="image" src="http://www.streamuj.tv/images/login.gif"
tabindex="5" class="loginbutton">
</p>
</form>
Please you have any idea how to create an automatic login with pre-defined values ​​, but not without abandoning the current page? Thank you very much in advance for your help and sorry for my English .

Related

Advance search function of google search using javascript but getting some problems

Below is the code of the form using which I'm trying to fetch the value for the query string.
<form id="form1">
<label for="allthesewords"> all these words</label>
<input type="text" id="allthesewords">
<br>
<label for="thisexactwordphrase">this exact word phrase</label>
<input type="text" id="thisexactwordphrase">
<br>
<label for="anyofthese">any of these</label>
<input type="text" id="anyofthese">
<br>
<label for="noneofthese">none of these</label>
<input type="text" id="noneofthese">
<br>
<input type="submit" value="Advance Search" onClick="advanceSearch()">
</form>
This one is the javascript function where I'm building my query string.
function advanceSearch(){
document.getElementById("form1").action="https://www.google.com/search?as_q="+document.getElementById("allthesewords").value+"&as_epq="+document.getElementById("thisexactwordphrase").value+"&as_oq="+document.getElementById("anyofthese").value+"&as_eq="+document.getElementById("noneofthese").value;
return true;
}
So, the actual problem is while clicking on the submit button it must redirect to this url
https://www.google.com/search?as_q=Harvard%20univeristy%20students&as_epq=students%20of%20Harvard%20Univeristy&as_oq=Harvard&as_eq=almamater
However, when I run my code it just redirects to this url:
https://www.google.com/webhp.
Thanks in advance!!!!!
<form action="https://www.google.com/search">
<p>Find page with</p>
<input class="input_bar" type="text" name="as_q" placeholder="all these words">
<input class="input_bar" type="text" name="as_epq" placeholder="this exact word or phrase">
<input class="input_bar" type="text" name="as_oq" placeholder="any of these words">
<input class="input_bar" type="text" name="as_eq" placeholder="none of these words">
<input id="btn" type="submit" value="Advance Search">
</form>
Use it!

JavaScript to automate a submiting a form

I am trying to automate the login of a web page using vanilla JavaScript.
This is the form on the web page:
<form id="tbb_logon_form" class="login_form" method="post" action="https://www.btopenzone.com:8443/tbbLogon" name="login_form">
<fieldset class="username-field">
<label for="email" id="lbl-email">BT ID</label>
<input type="text" id="username" name="username" class="required" tabindex="3" value="username" placeholder="This is usually your email address">
</fieldset>
<fieldset>
<label for="password">Password</label>
<input type="password" id="password" name="password" class="required" value="password" tabindex="4">
</fieldset>
<input type="submit" value="Login" id="lgnbtn" tabindex="5" id="loginbtn" onclick="var s=s_gi('btiopenzone'); s.linkTrackVars='eVar19,prop50'; s.eVar19='OZ|Home Hub|Landing Page|Account selected:BT Broadband'; s.prop50='OZ|Home Hub|Landing Page|Account selected:BT Broadband'; s.tl(this,'o','OZ|Home Hub|Landing Page|Account selected:BT Broadband');">
<input name="xhtmlLogon" type="hidden" value="https://www.btopenzone.com:8443/tbbLogon">
</form>
The things have tried are:
document.getElementById("lgnbtn").submit();
document.getElementById("lgnbtn").click();
but neither are automating the click of the login button.
Please help me.
You can submit your form using:
document.forms[0].submit();
or
document.forms["login_form"].submit();

My button didnt work

Hi i created a login form, but when i click on login i can't send username and password to db, with this code:
<a id="enter" href="#"><div id = "enterbutton">enter</"div></a>.
And i am able to send username and pass with this code:
<input id="enterbutton" type="submit" value="Login">
and now this button look ugly, because i have pic for this button added in my css. With this first code button look exactly how i want it to be. How to fix this?
My form look:
<form name="forma2" action="login.php" method="post">
<br>
<input class="inputbox" type="text" name="username" maxlength="18" placeholder="username">
<br>
<br>
<input class="inputbox" type="password" name="password" placeholder="password">
<br>
<input type="submit" value="Login">
</form>
Work's but without css.
If you want to use:
<a id="enter" href="#"><div id = "enterbutton">enter</"div></a>
Because you have a specific css you've applied to it, then simply do.
$('#enter').on('click', function(){
$('#form').submit();
});
Just remember to add an id to your form.
If you want to use a button as div you should declare in your JavaScript the .click() event how this:
$('#enter').on('click', function(){
$('#form[name="forma2"]').submit();
});
you can use anchor to submit form but you will use event handler:
<form id='myForm' name="forma2" action="login.php" method="post">
<br>
<input class="inputbox" type="text" name="username" maxlength="18" placeholder="username">
<br>
<br>
<input class="inputbox" type="password" name="password" placeholder="password">
<br>
<a id="enter" href="#" onclick='document.getElementById("myForm").submit()'><div id = "enterbutton">enter</div></a>
</form>
<form name="forma2" action="login.php" method="post" id="myForm">
<br>
<input class="inputbox" type="text" name="username" maxlength="18" placeholder="username">
<br>
<br>
<input class="inputbox" type="password" name="password" placeholder="password">
<br>
Submit
</form>
<script>
function submitMe() {
document.getElementById("myForm").submit();
}
</script>
The answer of #Grimbode is good. But I don't like to add more script and you may not have jQuery either. We can handle it with CSS only.
The problem with your <a> is you didn't add any handler for this, so whenever you click on this <a>, it won't do anything. <input type="submit"> is for form, it handles exactly what we want. But usually, the input come with some of default CSS, I don't like it, and you either.
You can find my sample for your case here:
https://jsfiddle.net/y7mvu9zn/

JQuery solution for AWeber Subscriber Form - No Redirect

How do i add some form of JQuery solution to the below code so that users are using the redirect but instead have a nice response back saying 'Thanks for subscribing'?
Also, is this the best way - The JQuery solution? Or should i try JS
<form method="post" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl" >
<div style="display: none;">
<input type="hidden" name="meta_web_form_id" value="1337" />
<input type="hidden" name="meta_split_id" value="" />
<input type="hidden" name="listname" value="blah" />
<input type="hidden" name="redirect" value="http://www.aweber.com/thankyou-coi.htm?m=text" id="1237" />
<input type="hidden" name="meta_adtracking" value="blah" />
<input type="hidden" name="meta_message" value="1" />
<input type="hidden" name="meta_required" value="name,email" />
<input type="hidden" name="meta_tooltip" value="" />
</div>
<input type="text" name="name" autocomplete="off" required placeholder="First name">
<input type="text" type="email" name="email" required placeholder="Your Email">
<input type="submit" name="submit" value="Subscribe">
</form>
Edit - But have it be presentable, i.e. I want to put the text within a DIV, not Alert the user with a pop up or redirect them to my page.
$("form").submit(function(){
alert("Thanks for subscribing");
});
edit ##
Stack overflow jQueryUI Modal confirmation dialog on form submission

separate validation of two forms with jquery

I have two forms in one page and i would like to validate each form separately DEPENDING on what the user fills. So basically the user must fill only ONE form and NOT both of them...SO basically if the user fills up form number 1, the validation will be on form 1 ONLY..
Below please find the code of both forms:
<form action="/registration.flow" method="post" id="formElem1" name="formElem1" autocomplete='off'>
<label for="Name_First">First Name:</label>
<input type="text" name="Name_First" id="Name_First" value="" class="required" maxlength="128" />
<label for="Name_Last">Last Name:</label>
<input type="text" name="Name_Last" id="Name_Last" value="" class="required" maxlength="128" />
<button id="registerButton" type="submit">Register</button>
</form>
<form action="/registration.flow" method="post" id="formElem2" name="formElem2" autocomplete='off'>
<label for="Name_First">First Name:</label>
<input type="text" name="Name_First" id="Name_First" value="" class="required" maxlength="128" />
<label for="Name_Last">Last Name:</label>
<input type="text" name="Name_Last" id="Name_Last" value="" class="required" maxlength="128" />
<button id="registerButton" type="submit">Register</button>
</form>
Can someone help me please?
You don't need jQuery specifically to do this. Simple javascript is fine. Call a separate function for the onSubmit of each form.
onSubmit="return validateForm1(this);"
and -
onSubmit="return validateForm2(this);"
Make sure you return true or false depending on if the form passed or failed the validation.
I recommend you the jquery validator . It's easy to use and you can do the two validations separately.

Categories