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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

733 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