Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

if else in submit jquery

Posted on 2014-11-08
5
211 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 109

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
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 Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

840 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