Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to make required field validater between 7000 to 11000?

plz help
Thanks in advance.
Posted

Hi neeraj,

To check if the textbox has values, use required field validator.
But to apply a check for the given range use this :

C#
<asp:rangevalidator runat="server" type="Integer" xmlns:asp="#unknown">
MinimumValue="7000" MaximumValue="11000" ControlToValidate="TextBoxId" 
ErrorMessage="Value must be a number between 4000 and 11000" /></asp:rangevalidator>


Hope this helps !! :)

Regards,
Praneet
 
Share this answer
 
Use the jquery to validate the numeric values:
$(document).ready(function() {   
  $('.error').hide();
  $('.submit').click(function(event){
    var data=$('.infobox').val();
    var len=data.length;
    var c=0;
    var num=0;
    var flag=0;
    for(var i=0;i<len;i++)>
    {
      c=data.charAt(i).charCodeAt(0);
      if(c <48 || c >57)
      {
        $('.error').show();
        flag=1;
        event.preventDefault();
        break;
      }
      else
      {
        $('.error').hide();
      }
    }
 
    if(flag==0)
    {
      num=parseInt(data);
      if(num<7000 || num>11000)
      {
        $('.error').show();
        $('.error').text('Invalid num. Please enter the num within the range 7000 to 11000');
        event.preventDefault();
      }
    }
  });
 });
 
Share this answer
 
The documentation[^] gently provides code samples.
 
Share this answer
 
<asp:rangevalidator runat="server" type="Integer" xmlns:asp="#unknown">
MinimumValue="7000" MaximumValue="11000" ControlToValidate="TextBoxId" 
ErrorMessage="Value must be a number between 4000 and 11000" /></asp:rangevalidator>
 
Share this answer
 
Comments
Thanks7872 20-Oct-14 4:52am    
See the first solution.

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