zoukankan      html  css  js  c++  java
  • JS 控制文本框必须输入值才能查询

    有俩文本框,必须输入其中一个才能查询

     <div>
                <table>
                    <tbody>
                        <tr>
                            <td>
                                <span class="min_label">ID</span>
                                @Html.TextBoxFor(model => model.Condition.ID, new { @class = "input_txt w130 textbox1" })
                            </td>
                            <td>
                                <span class="label">Name</span>
                                @Html.TextBoxFor(model => model.Condition.Name, new { @class = "input_txt w130 textbox2" })
                                <span class="field-validation-valid pnrticketno" data-valmsg-replace="true"><span class="">请填写查询条件</span></span>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <input type="submit" class="btn_sub ml60 submit" value="立即查询" />
                        </tr>
                    </tbody>
                </table>
            </div>

    <script type="text/javascript">       

    //移除提示    

    function removeError($class) {        

    $class.addClass("field-validation-valid").removeClass("field-validation-error");     }    

    //验证错误    

    function addError($class) {        

    $class.removeClass("field-validation-valid").addClass("field-validation-error");     }    

    //判断查询条件是否填写 移除提示信息    

    $(".textbox1").focus(function () {

            removeError($(".pnrticketno"));

        });    

    //点击查询 需验证的信息    

    $(".submit").click(function () {        

    if ($(".textbox1").val() == "" && $(".textbox2").val() == "") {            

    addError($(".pnrticketno"));            

    return false;         }     });

    </script>

  • 相关阅读:
    if elseif else
    java编程思想第四版中net.mindview.util包
    eclipse git插件配置
    php面试常用算法
    数据库字段类型中char和Varchar区别
    MySQL的数据库引擎的类型及区别
    windows系统中eclipse C c++开发环境的搭建
    launch failed.Binary not found in Linux/Ubuntu解决方案
    技术团队的情绪与效率
    如何有效使用Project(2)——进度计划的执行与监控
  • 原文地址:https://www.cnblogs.com/qianyindichang/p/3493719.html
Copyright © 2011-2022 走看看