如果警报不提交表格 [英] If Alert do not Submit Form

查看:90
本文介绍了如果警报不提交表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本字段和一个jquery代码,谁向我发出警报,则当第二个文本字段的值大于第一个文本字段的值时.我找到了代码,并且效果很好,但是我需要将这些控件转移到超链接,如果第二个文本字段的值较小,则超链接将提交以继续.如果不是,那么我想得到警报,而配方设计师无法提交继续

I have two textfields and a jquery code who who gives me an alert, when the value of the second textfield is greater then the value of the first Textfield. I found the code and it works great, but I need to transfer these control to an hyperlink, who submit to continue if the value of the second textfield is smaller. If it is not, than I want to get the alert and the formular can't submit to continues

$('#Sel2').change(function(){
    var inputGUVal = Number ($('#Sel2').val());
    var inputGULimit = Number ($('#Sel1').val());
    if (inputGUVal > inputGULimit){
        alert ('Choose a number below a ' + inputGULimit )
    }
})​

请参见对jsfiddle的操作

推荐答案

根据以下条件阻止提交:

Prevent submission based on the condition:

$("a").on('click', function (e) {
   if ($("#Sel2").val() > $("#Sel1").val()) {
      e.preventDefault();   
   }
});

http://jsfiddle.net/ExaVH/21/

这篇关于如果警报不提交表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆