Yes it is more reliable...
BUT pain in the a&*^*&^ for a user having to wait for a page to reload each
time..
3 things to do ..
1) Stop the user from entering it in the first place
2) before submit ensure it is NOT over the max length
3) check on server.
To stop the client side dont rely on the MS validatoin... it doesnt work for
most of your browser base..
try something like this for client side stuff...
<asp:textbox id="SearchDescription" runat="server" CssClass="body_text"
Rows="3" TextMode="MultiLine"
Width="173" onkeypress="return FilterMaxLength(event,this,60)"
onpaste="return CheckPaste(this,60)"></asp:textbox>
function CheckPaste(o,max){
var maxLength = max;
// Get from clipboard
var data = window.clipboardData.getData("Text");
var CurrentLength = o.value.length + data.length;
if (CurrentLength > maxLength)
return false;
else
return true;
}
function FilterMaxLength(e,o,max){
// we must allow spaces , backspace etc to go through
var iKeyCode, strKey;
if (isIE) {
iKeyCode = e.keyCode;
} else {
iKeyCode = e.which;
}
strKey = String.fromCharCode(iKeyCode);
// Make sure we let special keys go through.
if (isSpecialKey(strKey))
return true;
var maxLength = max;
if(o.value.length > maxLength-1){
return false;
}
return true
}
"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:ed****************@TK2MSFTNGP09.phx.gbl...
That will not prevent someone from submitting a longer string value from
an alternate UI. Server-side validation is a much more reliable way to
ensure that the submitted values meet expectations.
"Swanand Mokashi" <swanandATswanandmokashiDOTcomNOSPAM> wrote in message
news:uf*************@TK2MSFTNGP10.phx.gbl... use the maxLength property of the textbox?
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET)
Microsoft Certified Application Developer (.NET)
http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"A.M" <IH*******@sapm123.com> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl... Hi,
How can I use validation controls to check max length of string text
boxes?
Thanks,
Alan