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.
Related
Good morning,
I'm doing a basic website for the university.
I should provide a login form where the user can insert username and password... If those are correct a cookie is saved with username value; thanks to this cookie, when the user closes the session and opens again the browser to login, the username field is already there (I did this with a php script inside the form).
The only problem is that the button that should clear both the textfields in the form doesn't work.
<form name="f" action="controlAndErrorLogin.php" method="POST">
<p>Username: <input type="text" name="username" value=<?php if(isset($_COOKIE["username"])){echo "\"".$_COOKIE["username"]."\"";}else{echo "\"\"";}?>>
</p>
<p>Password: <input type="password" name="password" value=""></p>
<p>
<input type="submit" value="OK">
<input type="reset" value="PULISCI" onclick="document.getElementById('username').value = '';">
</p>
</form>
What is the problem?
Thanks
First of all, your input field is missing the id that you are trying to select it by.
Second, a reset button resets form fields to the default value they had specified in the initial HTML. You specified the user name in there, not an empty value - so that’s what the field will get reset to.
Third, .value = '' only resets the current value of the element, but not the default value. You need to set the actual defaultValue property, to achieve that.
<form name="f" action="controlAndErrorLogin.php" method="POST">
<p>Username: <input type="text" id="username" name="username" value="foo"></p>
<p>Password: <input type="password" name="password" value=""></p>
<p>
<input type="submit" value="OK">
<input type="reset" value="PULISCI"
onclick="document.getElementById('username').defaultValue = '';">
</p>
</form>
try to add attribute id="username" in the input tag with name="username"
I need to have a form with a button which on submit, check for required field but does not refresh the page.
<form>
<fieldset>
<input type="text" id="firstname" placeholder="First Name" required/>
<input type="submit" value="Send"/>
</fieldset>
</form>
If I disable on submit for form, it wont check for required fields anymore. I need all the functionality of onSubmit but without refreshing the page.
I will appreciate any help.
I'm unsure why you are getting an error. The code provided should work. Try adding an action and a method just in case as follows:
<form action="" method="POST" onsubmit="myFunction()">
<fieldset>
<input type="text" id="firstname" placeholder="First Name" required>
<input type="submit" value="submit">
</fieldset>
</form>
You can then add a function called myFunction down below as follows:
<script>
function myFunction() {
alert("Form was submitted");
}
</script>
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">
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
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.