Victor Charles
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.Cl ientID %>');
var txb = $('#C1RotationMin_C1TextBo x');
if (mskinput.get_text().trimE nd().lengt h < 6 && mskinput.get_text().trimEn d().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="C1RotationMi n_OnClient Blur" OnClientFocus="C1RotationM in_OnClien tFocus"/>
</td>
Thanks,
Victor
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
var mskinput = $find('<%=C1RotationMin.Cl
var txb = $('#C1RotationMin_C1TextBo
if (mskinput.get_text().trimE
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="C1RotationMi
</td>
Thanks,
Victor
ASKER
9 just allows me to enter only numerical values.
int ouput; is not recognized, i receive error: Expected ';'
int ouput; is not recognized, i receive error: Expected ';'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You!
try use int.tryParse to validate mskinput.get_text()
var txt = mskinput.get_text();
int output;
if(!int.TryParse(txt, out output)){
//invalid
}