如何解决正则表达式。 [英] how to solve regular Expression.

查看:77
本文介绍了如何解决正则表达式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Team,



正则表达式的代码如下:

On按钮点击我正在验证输入值。

 function validateValues(){

if ($( #batchIDSelect')。val()== ' ' || $(' #batchIDSelect')。val()== null ){
alert( 选择BatchID);
return false ;
}
var regExpBatchID = / ^ [0-9] * $ /;
if (!regExpBatchID.test($(' #batchIDSelect')。val())){
alert( 输入BatchId.No中的数字字符是允许的);
return false ;
}

if ($(' #deoIdSelect')。val()== ' ' || $(' #deoIdSelect')。val()== null ){
alert( 选择DEO ID );
return false ;
}
var regExpDEOID = / ^ [a-zA-Z0-9] * $ /;
if (!regExpDEOID.test($(' #deoIdSelect')。val())){
alert( DEOID Must只是数字和字母。);
return false ;
}

返回 true ;
}





按钮点击,我正在验证如下:

 $( #getCountButton)。click(function(){
调试器;
if (!validateValues()){
return ;
}

});





现在问题是如果它没有验证我看不到在页面上发出警告信息。为什么会这样?

它给出了正确验证的返回值,而不是不正确的验证。我需要两个验证。

请指导我我完全错了。

谢谢

Harshal。

解决方案

' #batchIDSelect')。val()== ' ' ||

' #batchIDSelect')。val()== < span class =code-keyword> null ){
alert( 选择BatchID );
return false ;
}
var regExpBatchID = / ^ [0-9] *


/;
if (!regExpBatchID.test(


Hello Team,

I have Code as follows for Regular Expression:
On button Click i am verifying the input value.

function validateValues() {

           if ($('#batchIDSelect').val() == '' || $('#batchIDSelect').val() == null) {
               alert("Select the BatchID");
               return false;
           }
           var regExpBatchID = /^[0-9]*$/;
           if (!regExpBatchID.test($('#batchIDSelect').val())) {
               alert("Type the Number in BatchId.No Characters are Allowed");
               return false;
           }

           if ($('#deoIdSelect').val() == '' || $('#deoIdSelect').val() == null) {
               alert("Select the DEO ID");
               return false;
           }
           var regExpDEOID = /^[a-zA-Z0-9]*$/;
           if (!regExpDEOID.test($('#deoIdSelect').val())) {
               alert("DEOID Must Be Number and Alphabets Only.");
               return false;
           }

           return true;
       }



on Button click ,i am Validating as follows:

$("#getCountButton").click(function () {
            debugger;
            if (!validateValues()) {
                return;
            }
         
        });



Now the problem is if it is not validate i cant see the alert message on page.Why it is so??
It gives me the return value for proper validations not for the incorrect validations.I need both validations.
please guide me where i am exactly wrong.
thanks
Harshal.

解决方案

('#batchIDSelect').val() == '' ||


('#batchIDSelect').val() == null) { alert("Select the BatchID"); return false; } var regExpBatchID = /^[0-9]*


/; if (!regExpBatchID.test(


这篇关于如何解决正则表达式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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