Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with validating length of data entered

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
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

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
}
Avatar of Victor  Charles

ASKER

9 just allows me to enter only numerical values.

int ouput; is not recognized, i receive  error: Expected ';'
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank You!