Click here to Skip to main content
15,889,695 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
HEllo Team,

I am in trouble . As The Code is very Simple.
C#
var regExpDEOID = /^[0-9]*$/;
           if ($('#topCountForQCTextbox').val() == '' || !regExpDEOID.test($('#topCountForQCTextbox').val())) {
               alert("Please enter proper values in allocation count");
               return false;
           }


I have the textbox namely topCountForQCTextbox
My validation is for if the textbox is empty and not equal to regExpDEOID.

But when i am inserting the value in textbox as 1 , it gives me message "Please enter proper values in allocation count" which is wrong as per my Regular Expression.

Please Guide me where I am getting wrong.
Thanks Harshal.
Posted
Comments
Sergey Alexandrovich Kryukov 15-Apr-14 11:38am    
It depends on the context of this code. Also, are you sure you have id="topCountForQCTextbox" for this control?
—SA
R Harshal 15-Apr-14 11:52am    
yes . i have ..
R Harshal 15-Apr-14 12:09pm    
I got my Mistake . u r right my ID was Wrong.
Thank you So much

1 solution

Please try is as below.
C#
var regExpDEOID = /^[0-9]*$/;
var topText=$('#topCountForQCTextbox').val();

if ($.trim(topText).length == 0 || !regExpDEOID.test($('#topCountForQCTextbox').val())) {

   alert("Please enter proper values in allocation count");
   return false;
}
 
Share this answer
 
Comments
R Harshal 15-Apr-14 12:00pm    
sorry to say ,But its not working.
Sampath Lokuge 15-Apr-14 12:02pm    
What's your regex does ? May be the problem with it.Check that.
R Harshal 15-Apr-14 12:09pm    
I got my Mistake . u r right my ID was Wrong.
Thank you So much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900