malsup wrote:
>
>
> You don't *have* to have a submit button on the form, but you really
> should. What if javascript is disabled? You still want the form to
> work, right?
>
> You can use your image as a submit element if you like:
>
> <input type="image" src="myImage.gif" />
>
Actually my code starts off with an image submit button (and the form works
well without javasript), but javascript swaps it for a standard image
because the transparency for the image doesn't work when it is used in an
input field. Here is the code (I renamed the form from "login" to
"frmLogin"):
The javascript:
function submitLoginForm() {
//validation is working so I know that the load form function worked
if ( ($("#username").val()=="" ) || ($("#passwd").val()=="" )) {
alert ("Please complete the username and password fields.");
return false;
}
//THIS IS THE PART CAUSING TROUBLE
$('#frmLogin')[0].submit();
}
function loadLoginForm() {
$("#submit-container").empty().append(" \"images/sign-in.png\" ");
$("#submit").keydown( function() {
//actually I'd like this event only to be linked to the enter key - haven't
worked that one out yet
submitLoginForm();
}).click(function(){
submitLoginForm();
});
}
Teensy bit of CSS:
.img_button {
cursor: pointer;
}
And finally the form:
<form action="index.php" method="post" name="frmLogin"
id="frmLogin">
<fieldset>
<legend> Sign in </legend>
<p>* Required fields</p>
<label for="username" class="followon" >User name:</label>
<br />
<input name="username" id="username"
type="text" size="20" tabindex="1" />
<br />
<label for="passwd" class="followon" >Password: *</label>
<br />
<input name="passwd" id="passwd"
type="password" class="followon" size="20" tabindex="2" />
<br />
<label for="remember">Remember me</label>
<input type="checkbox" name="remember" name="remember"
class="checkbox" value="yes" tabindex="3" />
<br /><br />
<div id="submit-container">
<input type="image" name="submit" id="submit"
value="Sign in" src="images/sign-in.png" tabindex="4" />
</div>
</fieldset>
<input type="hidden" name="option" id="option" value="login" />
</form>
--
View this message in context:
http://www.nabble.com/Form-not-submitting-tf3025179.html#a8419439
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/