Solved

if else in submit jquery

Posted on 2014-11-08
5
208 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
ID: 40430498
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
ID: 40430519
I can't replace the submit button it has a graphic on it.
0
 
LVL 108

Expert Comment

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

Accepted Solution

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

Author Closing Comment

by:designaire
ID: 40431576
Thanks so much!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

912 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

26 Experts available now in Live!

Get 1:1 Help Now