(HTML5,JQuery)JQuery忽略Input元素的属性 [英] ( HTML5, JQuery) Attributes of Input elements are ignored by JQuery

查看:75
本文介绍了(HTML5,JQuery)JQuery忽略Input元素的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML5中,当我创建如下所示的文本框并按提交"按钮时.

In HTML5, when I make a text box like below, and press the submit button.

<input type='number' name ='search_size' id ='search_size' class="" value="" min="0" max="100" >

当值不符合最小值,最大值时,它将不会继续.但是,

When the value doesn't meet the min, max value, it will not proceed. However,

我处理文本框的按钮由JQuery制成.当我什么都没键入,然后单击时,它将对其进行处理.当我输入的值超过100时,它也会对其进行处理. (还有其他标记等的其他值.)

My button that handles the text box is made of JQuery. When I type nothing, and click, it processes it. When I type the value over 100, it also processes it. (There are other values from other tags and etc.)

是否可以在JQuery中添加一些内容,以便它可以在文本框中检查条件或要求?

我想在这里显示JQuery代码,但是它很长.其中一些看起来像下面的样子.

I want to show the JQuery code here, but it is pretty long. Some of it looks like the below.

$("#search_submit").off("click").on("click", function(event_receiver){
        $("#loading").css('z-index',-1);
        $("#loading_search").css('top',$("#dialog_data_search").position().top + ($("#dialog_data_search").height()*0.7) );
        $("#loading_search").show();

        var search_data;
        var request_obj = {
                "baseDN" : $("#search_base_dn").val()
                ,"filter":$("#search_filter").val()
                ,"attribute":$("#search_attribute").val()   
                ,"sortAsc":true
                ,"scope":$(":radio[name='search_scope']:checked").val()
                ,"size":$("#search_size").val()};   //<--  this guy!!

        $.ajax({
            url:"/browser/ajaxGetSearchData"
            ,dataType:"json"
            ,data:request_obj
            ,async:true
            ,type:"post"
            ,success:function(return_data){
                if(return_data.success){                        
                    search_data = return_data.result;
                }else{
                    alert(return_data.message);
                }
            }

推荐答案

,您可以在自己的jquery click函数中添加一个validate函数.在该验证功能中,必须验证输入字段的值.如果超过100,则应返回false

you can add a validate function inside the jquery click function of yours. in that validate function the value of the input field must be validated. if it exceeds 100 it should return false

这篇关于(HTML5,JQuery)JQuery忽略Input元素的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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