Help with validating length of data entered

Posted on 2013-01-07
Medium Priority
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
  • 2
  • 2
LVL 42

Expert Comment

by:Meir Rivkin
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

Meir Rivkin earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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

569 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