Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with validating length of data entered

Posted on 2013-01-07
4
Medium Priority
?
187 Views
Last Modified: 2013-02-08
Hello,

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) {
                    alert("Invalid");
                    document.focus();
                    mskinput.focus();

                }

            };

<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"/>
                           
                    </td>



Thanks,

Victor
0
Comment
Question by:vcharles
  • 2
  • 2
4 Comments
 
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)){
//invalid
}
0
 

Author Comment

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

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

Accepted Solution

by:
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();
parseInt(txt)
0
 

Author Closing Comment

by:vcharles
ID: 38867791
Thank You!
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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

886 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