How to disable an autocomplete in jsp - javascript

My login.jsp page contain two input tag.One is text input another one is password.
In this page i enabled autocomplete.
<form name="login" autocomplete="on">
Once user login browser automatically enable autocomplete option.
My problem is after logout user goto signup page the email and password box is auto filled.
But this page i did not enabled autocomplete
<form name="signup" autocomplete="off">
How to solve this.
Signup page code:
<form action="/signup" method="post" name="signupform" autocomplete="off">
<input style="width: 80%" type="text" tabindex="2"placeholder="Enter email" name="email" id="email" autocomplete="off">
<input style="width: 80%;" type="password" tabindex="3"placeholder="8 character password" name="password" autocomplete="off" id="password" maxlength="20">

Related

Chrome rises autofill input event after clicking the page only

fill the form, save values in Chrome for Mac, then reload page.
alert will show only after page is clicked,
why is that? How can I get input events fired right after
page load, not after click? Thank you
link to reproduce the issue here,
this is source
Code of the example below:
<form action="https://test.de" method="POST" name="loginform">
<input oninput="alert('text')" type="text" id="name" placeholder="Username" name="username" />
<input oninput="alert('pass')" type="password" id="password" placeholder="Password" name="password" />
<input type="submit" />
</form>
<div class="log"></div>
<script>document.querySelector("input").focus();</script>

Overwriting iframe form field AND requesting information

I have an assignment for one of my classes where I need to bypass CSRF protection and login with a specific account even if the user inputs different credentials. Right now I did it in a kind of hack-y way that works when there is no CSRF protection (place an invisible submit button for my form on top of the iframe's submit button). Anyway, so how would I overwrite the username and password fields (using Jquery I presume) of the iframe when the login button (in the iframe) is pressed?
mytest.com:
<html>
<head><title>mytest.com</title></head>
<body>
<iframe id="testFrame" src="test.com" allowfullscreen width="110%" height="900px"></iframe>
</body>
</html>
test.com:
<form method="post" class="form-inline" id="form0">
<input id="user" name="user" type="text" placeholder="username" required>
<input id="pass" name="pass" type="password" placeholder="password" required>
<button id="submitBut" type="submit" formaction="test.com">login</button>
</form>

autocomplete false is not working in the input fields

I am facing issue with autocomplete false. Can anyone please give the best solution for it?
current html:
<form name="register" action="" method="">
<input type="text" id="email" placeholder="Username" name="email" autocomplete="false">
<input type="password" id="password" placeholder="Password" name="password" autocomplete="false" required>
<div id="submit" type="submit">Let me in!</div>
</form>
Remove all autocomplete from input fields and add:
<form action="" method="post" autocomplete="off"> in replacement of your initial <form> tag
This will disable the autocomplete completely on the form.
There is a glitch where it autocomplete on the last input field.
A simple trick is to add input text field with:
style="display: none;"
as the last input field.

Simulate a submit button click via JavaScript

Is it possible to Submit a form with JAVASCRIPT? if yes please help me...
I have a form with input fileds in it. So I want javascript to count if all fields are field in and then press on the submit button.
The submit button "Save" will be hidden from visitors eyes.
<form id="my form" action="">
<input type="text" name="fname" id="fname" value=""/>
<input type="text" name="sname" id="sname" value=""/>
<input type="text" name="email" id="email" value=""/>
<button type="submit" name="submitAccount" id="submitAccount">save</button>
</form>
here is a opened FIDDLE
Thanks to all for any help!
you can submit form via JavaScript even without submit button, form element has method .submit() which submits whole form.
var myForm = document.getElementById('myform');
myForm.submit();
Before submiting form you can get values from every field in form and make you own validation.
P.S. don't use values for id attribute with whitespace, you should rename it to 'myform' or 'myForm'.
There is a required attribute
<form id="myForm" action="">
<input type="text" name="fname" id="fname" value="" required/>
<input type="text" name="sname" id="sname" value="" required/>
<input type="text" name="email" id="email" value="" required/>
<button type="button" name="submitAccount" id="submitAccount" onclick="checkForm();">save</button>
</form>
Form gets submitted only if the required fields are filled

Hiding and showing Divs with form validation

Upon submit I am trying to have "quiz" hide and have "thanks" be shown. All was working correct until I added a JavaScript form validation code, and now it just reloads the first div "welcome" I thought adding "#thanks" to the action upon submit would solve the issue, but it did not. Then trying to add an "if true" statement to my form validation ended up breaking the form validation. I am using jquery.validate to validate my form as suggested. With the current code it skips the validation and just shows "thanks" If anyone has any suggestions it would be greatly appreciated.
<div id="quiz">
<form class="cmxform" id="commentForm" method="get" action="" onSubmit="showHide(); return false;">
<label for="cname">Name</label>
<input id="cname" name="name" size="20" class="required" minlength="2" />
</p>
<p>
<label for="ccompany">Company Title</label>
<input id="ccompany" name="company" size="20" class="required company" minlength="2" />
</p>
<p>
<label for="cnumber">Phone Number</label>
<input id="cnumber" name="number" size="20" class="required number" />
</p>
<p>
<label for="cemail">Email</label>
<input id="cemail" name="email" size="20" class="required email" />
<p></p>
<input class="submit" type="submit" value="Submit" align="center"/>
</form>
</div>
<div id="thanks"><h2>Thank you.</h2>
You will receive an email momentarily
</div>
<script>
$("#begin").click(function(){
$("#quiz").show();
$("#welcome").hide();
});
function showHide(){
$("#thanks").show();
$("#quiz").hide();
};
</script>
All I can say is that you are doing it wrong.... While the form validation that you are doing can work there are a lot of good form validation jquery plugins that would both simplify your life and add a much richer user experience. jquery.validate is probably the most widely used library and would be well worth using.

Categories