-6

I want use my own button in form

When i'm using

<form method="post" action="check_login.php">
    <input class="textbox" name="username" type="text" placeholder="Login">
    <input class="textbox" name="password" type="password" placeholder="Password">

    <div id="buttonPlace">
        <p>Remember Me</p>
    <input type="submit" value="Log in!" />

</form>

it works great. I would like to use my own button. When Im using this code :

<form method="post" action="check_login.php">
    <input class="textbox" name="username" type="text" placeholder="Login">
    <input class="textbox" name="password" type="password" placeholder="Password">

    <div id="buttonPlace">
        <p>Remember Me</p>
    <div id="buttonLogin" type="submit">sing up</div>

</form>

Button doesn't work. Why?

4
  • 2
    You cannot assign types to a div. You can however submit the form using JQuery when doing a click on the div.
    – Peter
    Commented Dec 23, 2014 at 13:19
  • 6
    pls .. try to read and understand basic html - tags <div type="submit" where have you found such thing?
    – donald123
    Commented Dec 23, 2014 at 13:20
  • 2
    You could change <Div tpe="submit"> to <button type="submit"> though
    – Peter
    Commented Dec 23, 2014 at 13:21
  • I think you just want to be able to style your button in which I would recommend you here: stackoverflow.com/questions/17236018/how-to-style-submit-button Commented Dec 23, 2014 at 13:24

3 Answers 3

1

<form method="post" action="check_login.php">
  <input class="textbox" name="username" type="text" placeholder="Login">
  <input class="textbox" name="password" type="password" placeholder="Password">
  <div id="buttonPlace">
    <p>Remember Me</p>
    <button id="buttonLogin" type="submit">Sign up</button>
  </div>
</form>

1

Div can't have type="submit" property, only form inputs can have different input types property. If you want to style your submit button, use:

<input class="submitbutton" type="submit">Sign up</input>

and then define css style for your button class:

.submitButton {
   .width: 60px;
   .height: 20px;
   .color: #dd5599;
}
0

If you want to submit form on click of your div, use need to assing its click a function to sumbit the form :-

$( document ).ready(function() {
$( "#buttonLogin" ).click(function() {
 $( this ).closest("form").submit();
});
}

However, it is better to use button or input for submission.

Not the answer you're looking for? Browse other questions tagged or ask your own question.