• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Jquery / HTML problem


See following Jquery

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script type="text/javascript" src="jquery/jquery.lightbox_me.js"></script>
                  $(document).ready(function() {
                        $('#button').click(function(e) {
                                    closeClick:      true,      

$(function() {
    $( "#adddate" ).datepicker();
    $( "#datecompl" ).datepicker();
      $("#cleardc").on('click',function () {
      $("#clearal").on('click',function () {

This html:

            <td align="right">Date Completed:&nbsp;</td>
            <td><input name="datecompl" id="datecompl" type="text" class="pt12" size="12" readonly="readonly">&nbsp;<button id="cleardc">Clear date</button></td>

When the Clear Date button is clicked, it clears the date but submits the form.

Why does it submit the form? Is the button element considered a submit element?
Richard Korts
Richard Korts
1 Solution
Chris StanyonCommented:
You'll need to prevent the default behaviour of the button. You can do this with the preventDefault() method of the function's argument - e in the example below:

$("#cleardc").on('click',function (e) {

Open in new window

Richard KortsAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now