Solved

if else in submit jquery

Posted on 2014-11-08
5
219 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
[X]
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
  • 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 110

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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

617 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