Help with validating length of data entered

Posted on 2013-01-07
Last Modified: 2013-02-08

I am usin the code below to make sure users enter all data in MaskedInput control, but when the user enters only one number a the end, for example ___,___9, the "Invalid" error message  does not trigger. How do i fix this problem?

function C1RotationMin_OnClientBlur(sender, e) {

                var mskinput = $find('<%=C1RotationMin.ClientID %>');
                var txb = $('#C1RotationMin_C1TextBox');
                if (mskinput.get_text().trimEnd().length < 6 && mskinput.get_text().trimEnd().length > 0) {



<td class="style40" bgcolor="Silver" >
                        <cc2:C1MaskedInput ID="C1RotationMin" runat="server" Mask="999,999"
                            Width="50px" style="top: 0px; left: 0px" OnClientBlur="C1RotationMin_OnClientBlur" OnClientFocus="C1RotationMin_OnClientFocus"/>


Question by:vcharles
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 42

Expert Comment

ID: 38750667
what is the valie of mskinput.get_text(), when you enter 9?

try use int.tryParse to validate mskinput.get_text()

var txt =  mskinput.get_text();
int output;
if(!int.TryParse(txt, out output)){

Author Comment

ID: 38750727
9 just allows me to enter only numerical values.

int ouput; is not recognized, i receive  error: Expected ';'
LVL 42

Accepted Solution

sedgwick earned 500 total points
ID: 38750749
C1RotationMin_OnClientBlur is code behind or client side?

if client side use:
var txt =  mskinput.get_text();

Author Closing Comment

ID: 38867791
Thank You!

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question