.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

character limit in textbox in range validation

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
Hey,I am inserting some text in texbox and there is range validation set as minimum as 10 and maximun as 100. But when i run the program, though i insert the text atleast or more than 10 characters, it is showing the error message of this range validation. So I am confused how to set range so that user has to input atleast 10 character minimum ?

View Complete Post

More Related Resource Links

Textbox multiline How to set character limit?



I would like to put 250 characters limit to my textbox.

How can i do it?

Best Regards

How to disable textbox causing validation?

Hello I was running into a strange problem: If I left a textbox blank (in some instances) the textbox would not give up the focus (I could not even close the form).  I learnt later that this was because the text in the textbox was causing validation to fail.  I would have to type in some value (Satisfy validation) before i could close the form. This is problematic for me and I don't want the textbox to behave this way (I do not awnt front end validation).  I desire to have validation done ONLY on the back end.     I thought that I could solve this problem by changing the 'CausesValidation' property in the textbox to false.  This worked!  However it introduced a new problem.  The binding no longer worked on the Textbox.  That is, whatever value I typed in the textbox would not make it to the data set. What is the correct way in solving this problem???  I want validation to be shut off however I still (obviously) need to keep binding in tact...      

Issue with validation using IDataErrorInfo with int range

Hi, I have a textbox which takes only numbers as input. Textbox has binding with int type property. <TextBox Name="TXT_From" Text="{Binding Path=Range, UpdateSourceTrigger=LostFocus,<br/>  ValidatesOnDataErrors=True, Mode=TwoWay}" /> public int Range { get { return (int)GetValue(RangeFromProperty); } set { SetValue(RangeFromProperty, value); } } public static readonly DependencyProperty RangeFromProperty = DependencyProperty.Register("Range", typeof(int), typeof(MyClass)); In IDataErrorInfo I am doing some auto correction of values. public string this[string property] { get { string msg = null; switch (property) { case "Range": if (Range < 0) Range = 1; if (Range > Max) Range = TempMax; break; default: throw new ArgumentException("Unrecognized property: " + property); } return msg; } } Now the issue is when I enter value greater than 2,147,483,647 which is max value for int the IDataErrorInfo member public string this[string property] is not getting called,also it displays red bordered textbox. I want to avoid this validation and dont want restriction on value input. How to achieve this?  

Want to page content based off of a character limit or height of container

First of all I would like to say hello. I have created a backend that allows me to update my site content. I am using fckeditor to pull the data from my table in the database. The problem I am having is this:  I need to create paging of content so that when the height restriction is met a next btn or numbering system displays to allow the user to click to the next page of content. Can anyone point me in the right direction or possible tell me how I can do this?

Textbox Changed Validation - Best practise

I think is no secret that textbox validations on the TextChanged event is no secure. I mean there are some ways to avoid the control to raise de event.   One way used by me to validate is to delegate a button click into the blur attribute. First I create a normal button into a hidden div and then add this code in the page load: TextBox1.Attributes.Add("onblur", "document.getElementByID('Button1').click())   What I want to know is the best way to validade a textbox, because on my way there are problems in the navigation because if you dont set a focus on the next control in the Button Click the TAB INDEX navigation gets corrupted, if you do, the MOUSE NAVIGATION is avoided. So.. I hope somebody can help me to find the BEST PRACTISE to validade a textbox in the textchanged momento. thanks.  

javascript for field validation on a textbox...

I'm looking at doing the validation for the email in javascript since we have asp.net 1.1. I can get it to just alert fine, but once I add the return validation it doesn't fire. Me.ImageButton2.Attributes.Add("onclick", "return validation(this);") <script language="JavaScript"> <!-- function validation () { var test=""; test = document.ticketForm.emailAddress.value; if (test == "xyz") { alert(test); return false; // validation failed } --> </script>

Can Attribute limit the data range?

Can I write something like    public struct ID { public SerialPort port; [Range(0,31)] public int siteNumber;<span style="white-space:pre"> // limited to [0, 31] }   to ask Attribute to check the data range? Does .NET provide predefined attribute to do such thing? Or, who can give some suggestions to do such check/limit ? Thank you very much!

Identity Range Value (Max Limit Finished) SQL Server 2005 (Merge Replication Problme)


Hi ,

I am using SQL Server 2005 enterprise edition, I Confirured the Merge Replication to my database). I have a replication of 21 database from various locations.

Problem is: When is trying to remove one subriction from the publisher and add a fresh subriciton to it. it is poping any error saying the Identity Range value exceed its Max Limit try to change from int to bigint. is there any solution for it not changing from int to bigint.

Thank you.


What wouldbe the best approach to accomplish validation as you enter into textbox


Here is what im wanting to do, i believe i have seen it done, but cant remember if it was while you were typing or at validation. But i think at validation would be fine.

We have a form that will allow you to enter an IP address. In the table, that is the primary key. I would like to validate either during the entry or upon submission if that value is already in the table, if it is, then they cannot submit.

Would it be best to use a compare validator and compare the entered value with a list of values returned from the table?

Any suggestions on how to accomplish would be great. 

How do I adjust the word/character limit in Announcement web parts?


So In 2007 there was a default limit of 250 characters in annoucement web parts, that could be adjusted via the "Limit Len=" in designer, but I do not see anything close to that in 2010 and that limit is simply too small for real use.

I have the following text "Items focused on helping you develop and implement strategies are included on this page.  If you are looking for either the Strategic Solutions Team (SST) or the Sales Resource Hub...you found it!  We will continue to refine and add materials to Strategy to help you win...period!"

That gets cut off with half a sentence to go.  Honestly, who is the genius who put such a small limit on this web part and then removed the only way to adjust it via designer? 



clipboard validation before pasting into a textbox


I have a textbox with a keypress event tied to it to prevent only numbers, backspace, and 1 decimal point being entered into it. It works fine for when someone is typing into the textbox, but I also need to validate what could be pasted into the textbox from the clipboard. Right now, the pasted text could be anything, and it's giving me errors.

Here is my code so far:

private: System::Void PreventInvalidKeyOnKeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) 
			TextBox^ cur_control = dynamic_cast<TextBox^>(sender);
			// Only allow 1 decimal point (from http://www.daniweb.com/forums/thread310070.html)
			if (e->KeyChar == '.')
					if (cur_control->Text->Contains(".") && !cur_control->SelectedText->Contains("."))
						e->Handled = true;
			// Accept only digits ".", CTRL-C, CTRL-V, and the Backspace character

Range Validation


i have text in which i want when the user  lose the focus from the textbox...it should get error message saying please enter the number between 1 and 8.

Limit characters in multiline textbox on formview



I have this working perfectly on a normal webform without a master page or formview.

Label1 is counting the values in TextBox2 and limiting them to 10.

I need this to work in a formview with a master page but I just can't get it to work. Can someone please advise how I use this with the controls being in a formview or even a detailsview.

Thanks for any help.

    function checkLength(con)

if(con.value.length >= 10)

return false;



document.getElementById('Label1').innerHTML = (9 - con.value.length) + ' Chraracters Remaining';return true;


function setRemaining()

document.getElementById('Label1').innerHTML = (10 - document.getElementById('TextBox2').value.length) + ' Chraracters Remaining';

if (document.getElementById('TextBox2').value.length > 10)

document.getElementById('TextBox2').value = document.getElementById('TextBox2').value.substring(0,10);



WPF TextBox validation not appening


Hi everyone,

I'm currently developping an application in wich I'd like to validate the input in TextBox.

So I have made my code following exactly this sample : http://weblogs.asp.net/monikadyrda/archive/2009/06/24/wpf-textbox-validation.aspx

But nothing append, I have put a breakpoint in my validate method but it doesn't seem to pass through.

I have no idea of what I'm doing wrong with this.

Could you please help me?

Thanks a lot.


How to prevent Loss of Focus if there is Validation error on a textBox?

Hi i have a TextBox displayed as a TreeViewItem and when the user enters text and Tabs away or clicks somewhere else i want the control to retain focus if there is any validation error.Is there anyway i can do that? I am adding the ValidationRule to the TextBox created dynamically in code..I do see the default redborder when there is a validation error.I just want to force the user to correct the error and not go anywhere else in the app until its fixed..
Thanks in advance...

Making the Validation Error on TextBox thicker


A few of my users would like the validation error on the textbox to be more prominent. 

I have added this to my ResourceDictionary...

<Style TargetType="{x:Type TextBox}">
  <Trigger Property="Validation.HasError" Value="true">
   <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
   <Setter Property="BorderThickness" Value="3" />
   <Setter Property="FontWeight" Value="Heavy" />

The text does indeed go heavy on validation, but the red outline stays the same.  I am guessing BorderThickness is not the correct property to set.

  1. What is the appropriate property to set?
  2. Is there a place to look at what the WPF default is for TextBox Validation.HasError?

Dynamic TextBox Validation not working on dynamic DataGrid on PlaceHolder



I have a placeholder to which I programmatically add DataGrids... In the DataGrids, I programmatically add TextBoxes along with dynamic validations. Somehow, the DataGrids show up, but the dynamic validations don't work. If I set them to static, the blank space for them appears, but still, they wont work.

I'd appreciate your help on this.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend