I have a login script based on PHP and Javascript. I couldn't figure out for the longest time why it would work in chrome and safari but not in firefox or internet explorer. I finally figured out the issue is with the html, instead of having the regular submit button I have an image for submit. and simply changing type="image" to type="submit" resolves the issue. Does anyone know why this is and if there's a compatible way to write the following
This works:
<input name="doLogin" type="submit" style="margin-left:90px;" id="doLogin3" value="Login">
This does not:
<input name="doLogin" type="image" src="login-btn.png" style="margin-left:90px;" id="doLogin3" value="Login">
if you are not going to be using js to submit your form, then the input type for your submit button should be submit. but if you really must have an image in place of your button, just position the image with css by setting it as the background of your button. no need to change input type to image. hope that helps.
Related
I have a form with <input type="submit">. In Chrome submit doesn't do anything. On a Network tab in developer tools I see nothing. No errors in developer tools either. Meanwhile, if I do save a page and open a saved page, then after I press submit button, I see something appears in Network tab. This happens in Chrome and Firefox. This works as expected in IE.
Does anybody have a hindsight, what should I look at?
I don't need a direct answer, I only need to know, where should I look at. If someone posts a direction and that'll help me to solve my problem, I'll accept it as a correct answer.
Structure of a page looks like this:
html
head
body
div
div
form
form
form
form
form
input
input
table
table
tbody
tr..td..input type=submit
If you are not using any JavaScript for form validation then a simple layout for your form would look like this:
<form action="formHandler.php" method="post">
<input name="fname" id="fname" type="text" value="example" />
<input type="submit" value="submit" />
</form>
You need to ensure you have the submit button within the form element and an appropriate action attribute on the form element is present.
For a more direct answer, provide the code you are working with.
You may find the following of use: http://www.w3.org/TR/html401/interact/forms.html
Are you using HTML5? If so, check whether you have any <input type="hidden"> in your form with the property required. Remove that required property. Internet Explorer won't take this property, so it works but Chrome will.
I faced this problem today, and the issue was I was preventing event default action in document onclick:
document.onclick = function(e) {
e.preventDefault();
}
Document onclick usually is used for event delegation but it's wrong to prevent default for every event, you must do it only for required elements:
document.onclick = function(e) {
if (e.target instanceof HTMLAnchorElement) e.preventDefault();
}
Hello from the future.
For clarity, I just wanted to add (as this was pretty high up in google) - we can now use
<button type="submit">Upload Stuff</button>
And to reset a form
<button type="reset" value="Reset">Reset</button>
Check out button types
We can also attach buttons to submit forms like this:
<button type="submit" form="myform" value="Submit">Submit</button>
Check if you are using any sort of jquery/javascript validation on the page and try disabling it and see what happens. You can use your browser's developer tools to see if any javascript file with validate or validation is being loaded. You can also look for hidden form elements (ie. style set to display:none; or something like that) and make sure there isn't a hidden validation error on those that's not being rendered.
I ran into this on a friend's HTML code and in his case, he was missing quotes.
For example:
<form action="formHandler.php" name="yourForm" id="theForm" method="post">
<input type="text" name="fname" id="fname" style="width:90;font-size:10>
<input type="submit" value="submit"/>
</form>
In this example, a missing quote on the input text fname will simply render the submit button un-usable and the form will not submit.
Of course, this is a bad example because I should be using CSS in the first place ;) but anyways, check all your single and double quotes to see that they are closing properly.
Also, if you have any tags like center, move them out of the form.
<form action="formHandler.php" name="yourForm" id="theForm" method="post">
<center> <-- bad
As strange it may seems, it can have an impact.
You can't have a form element as a child (directly or indirectly) of another form element.
If the following does not return null then you need to remove the excess form elements:
document.querySelectorAll('form form');//Must return null to be valid.
check your form is outside the table
I'm trying to use a type="image" for a submit button. Not it is not working.
<input type="image" SRC="http://bin.xxx/images/free_download_continue.png" name="method_free" value="Free Download">
will not work for
<input type="submit" name="method_free" value="<TMPL_VAR lang_free_download>">
When I do this I http://jsfiddle.net/DXBgp/ get an error
but when I do this http://jsfiddle.net/EFjbx/ it works
Well I think you got them mixed up, http://jsfiddle.net/DXBgp/ works and http://jsfiddle.net/EFjbx/ doesn't, correct ?
Check out this question at: how to set background image in submit button?. You should just be able to add a background image using CSS on the button.
(I just finished developing my new site and I am testing if it works in all browsers. I need everything to be perfect.)
I have a form:
<form action="example.php" method="post">
<input type="text" name="example">
<input type="submit" name="button" value="Submit">
</form>
Everything in this form works fine in Chrome, Opera and FF, But in IE6 it doesn't.
When I press enter, it doesn't do anything. The form doesn't get submitted.
So I have to go over to the submit button with my mouse and click it if I want to submit.
Is there any way to fix it?
Check for Javascript that might be preventing you from achieving the expected behavior.
And please, consider dropping support for IE 6. IT IS ALREADY 10 YEARS OLD!!!!!!
I came upon a revelation the other day. When attempting to create a submit button by using an image, I ran into a problem where the image was not displayed but the value text was. At the time, this is not what I wanted, but now, as I look back, I see some potential use for this.
If you need to send data to another page, but none of it requires user input, you can either send it in the link (or form) via GET or through a form via POST. The problem is that the former creates ugly URLs and the latter requires a submit button that looks out of place. Of course, I could come up with an image, but what if I just wanted selectable text.
So, I started playing around a bit and Firefox appears to render the following how I desire, as a clickable link that submits a form. All you have to do is remove the src attribute from the input type='image' tag:
<form action='some_page' method='post'>
<input type='hidden' name='email_address' value='test#test.com' />
<input type='image' value='E-mail User' />
</form>
Does this solution work on other browsers? What are the downsides to doing this (aside from the obvious fact that your link CSS isn't applied properly)?
There's no need to use an image input, why not just use a regular submit button and apply some heavy-handed styling to make it look like regular text?
<input type="submit" value="E-mail User" class="link">
<style>
input.link {
border: none;
background: none;
cursor: pointer;
/* etc */
}
</style>
I like a solution that uses an actual link (hidden) that gets exposed via javascript in conjunction with a button inside a noscript tag.
<form action="some_page" method="post">
<input type="hidden" name="email_address" value="test#test.com" />
E-mail User
<noscript>
<input type="submit" value="E-mail User" />
</noscript>
</form>
$('submit-link').click( function() {
$(this).closest('form').submit();
return false;
})
.show();
Using HTML 4.01 Strict it worked on FF3.5, but not on IE8 or Chrome. The link works, but there is no text just a blank spot for a missing image.
So, this would appear to be a bad idea, since it may only work on one browser. To me that is a pretty big downside, unless your only market is for Firefox browsers, then, go ahead, great idea. :)
As James Skidmore suggested, it is easy to do an onclick with javascript to submit it as a post.
I would suggest unobtrusive JS, so, if someone doesn't have JS on then it will work as a link, doing a GET submission, but if they have JS then it would change the behavior to be POST with no ugly url change.
Or, as was mentioned the background of the image can blend in with the form background.
You could instead submit the form dynamically via JS, or use a regular submit button with a transparent or white background.
I have an html form and the submit button says "submit query". How can I remove this text? I am using a background image for the submit button and this text is messing up the button :( Any help would be greatly appreciated.
If you do not give your submit button a value
<input type="submit" />
instead of something like
<input type="submit" value="Submit" />
it will display 'submit query' by default. Try giving it a space as the value.
use:
<input type='submit' name='btnTest2' value=''>
Leave the value blank and there will be no words on the button. Since you're using a background image a for the button, give the button a height and width, otherwise it will display as a small gray blip (because there are no words on the button).
Background images are not content. If you want to use an image to tell people what a submit button will do, use a real image. As a bonus that allows you to provide alternative text for users who cannot see the image (e.g. because it failed to load or because they are blind).
<button type="submit">
<img src="example.png" alt="Submit">
</button>
Just use the value attribute as shown below:
<input value="Whateveryouwant" type="submit">
You just have to give it a value:
<input type='submit' name='btnTest'>
<input type='submit' name='btnTest2' value='Push Me'>
In the example above, btnTest renders as "Submit Query" while btnTest2 renders as "Push Me". Hope this helps.
UPDATE: You can do this to not display any text.
<input type='submit' name='btnTest2' value='' style="width:100px;">
Not sure if this was relevant then, but we would use type="image" rather than type="submit"
Just put a space between the value quotes. Simple fix.
Read the question before you reply. You may actually help someone.
Unfortunately, this does not work, at least not in a CMS. I've tried the space and the but IE8 will not recognize it. If I put the same in the value, it reverts back to 'Submit Query'. Just updating for anyone else who finds this method through a search.
EDIT : I added text indent: -9999px; to my CSS, and it seems that it worked. I still added the space in the value attribute for good measure.
I had this issue as well. If you don't set a value for a submit button it defaults to "Submit Query". I assume you are using an image for your submit button since you have the default value.
If you want to fix it for IE8 add a text indent using CSS which will push the default value off the screen.
text-indent:9999px;
If you want to fix it for IE9 you also need to change the default value because the text-indent doesn't work :( in your submit button add the following:
value=" "
I found this to work without a non-breaking space and tested it to my satisfaction on the IE's on browserstack. If you want to use the breaking space, feel free; I'll include the code.
value=" "
Also, thank you to the other stack-responders, you helped me fix this issue on IE9.
Also you inspired me to post my findings here and possibly help others!
If you are using something like a jQueryUI dialog button then you do not want to have the input button show up in the form, but rather just have it in the footer of the dialog. I accomplished this by doing the following:
Because IE will automatically put in an <input type="submit" /> I put this in the form instead: <input type="submit" style="display:none" />
Then later in the dialog JavaScript I put:
$("#register-dialog").dialog({
title: "Register",
modal: true,
width: 700,
buttons: {
Register: function () {
$('#registrationForm').submit();
},
Close: function () {
$(this).dialog("close");
}
}
});
Just remove the text with jQuery?
jQuery:
$('#btnSubmit').val('');
Plus the solutions mentioned with HTML and jQuery, you can put
font-size: 0px;
for the input and it wouldn't show the text anymore.
This worked in my case.
that's it browser show default use this
value="submit" is important
use attribute value="submit"
nothing just do this
<input type="submit /"
a slash with a space and u will not see the Submit or Submit Query no need to give value