Solved

if else in submit jquery

Posted on 2014-11-08
5
204 Views
Last Modified: 2014-11-09
I'm trying to put a condition in a JQuery submit button.  I'm not sure how to do it.

 $("#submit").click (function get(){
      if (counter>0){
      medLength=0;
      }      


/*      it works fine without this but I need this condition
if (medLength == 0 && counter == 0){
             $('.errorStop').css().show;
      }
      else{*/
 
/*AJAX*/

$.ajax({
                    url: "postnew1.php",
                    type : "POST",
                    data: { type: medType, time: medLength, length: counter },

                        }).success(function (response){
                        location.href = "meditate.php";                                            
                        }).error(function (e){
                        // console.log("error", e)
                        });

                  });
0
Comment
Question by:designaire
  • 2
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
replace yiur submit button by a normal button

<input type="button" name="mySubmit" id="mySubmit" value="Submit"  />

$("#mySubmit").click (function() {
0
 

Author Comment

by:designaire
Comment Utility
I can't replace the submit button it has a graphic on it.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Uhh, what about using CSS to style the input control?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
replace :
 $("#submit").click (function get(){
by :
 $("#mySubmit").click (function(evt) { // change its name and id too
   evt.preventDefault();
0
 

Author Closing Comment

by:designaire
Comment Utility
Thanks so much!!!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn how to dynamically set the form action using jQuery.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now