473,765 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add a Validator for a TEXTBOX with TextMode = multiLine

RSB
Hi Guys..
its me again.. ;o))

now i have a TextBox with properties Textmode = singleline and MaxLength =
100. So this works fine and i cannot enter more then 100 Chars. But as soon
as i change the TextMode to MultiLIne the MaxLength gets ignore as it is
painted as TEXTAREA. so how do i add a validator control to make sure that
user is not entering more than 100 Characters..

Thank you for the help in advance.

RSB.

Nov 18 '05 #1
3 3232
you cant use MaxLength with a multiline.You'l l have to use a CustomValidator
I believe and manually check the length of the string.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"RSB" <rs*****@hotmai l.com> wrote in message
news:T2******** ********@news.c pqcorp.net...
Hi Guys..
its me again.. ;o))

now i have a TextBox with properties Textmode = singleline and MaxLength = 100. So this works fine and i cannot enter more then 100 Chars. But as soon as i change the TextMode to MultiLIne the MaxLength gets ignore as it is
painted as TEXTAREA. so how do i add a validator control to make sure that
user is not entering more than 100 Characters..

Thank you for the help in advance.

RSB.

Nov 18 '05 #2
Hi

You have to use javascript & you should check the length on the server also

Basic example:
<textarea onkeydown="if(t his.value.lengt h >= 100){alert('Onl y blah'); return
false;}">

More info
http://msdn.microsoft.com/library/de...ence_entry.asp

--
Best Regards
Vidar Petursson
=============== ===============
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
=============== ===============
"RSB" <rs*****@hotmai l.com> wrote in message
news:T2******** ********@news.c pqcorp.net...
Hi Guys..
its me again.. ;o))

now i have a TextBox with properties Textmode = singleline and MaxLength
=
100. So this works fine and i cannot enter more then 100 Chars. But as
soon
as i change the TextMode to MultiLIne the MaxLength gets ignore as it is
painted as TEXTAREA. so how do i add a validator control to make sure that
user is not entering more than 100 Characters..

Thank you for the help in advance.

RSB.

Nov 18 '05 #3
try this the following, this will prevent user from entering more
characters than maxLen specified; it works in all the situations,
including:
1) copy and paste;
2) insert key on;

<HTML>
<HEAD>
<SCRIPT>
function fun_pTextarea_M axLen(prm_oText area_Obj)
{ var var_sKey_Code, var_aKey_Specia l, var_bResult,
var_oTextarea_T xtRng;

var_oTextarea_T xtRng = prm_oTextarea_O bj.createTextRa nge();
var_aKey_Specia l = [8,17,18,27,33,3 4,35,36,37,38,3 9,40,45,46,114];
var_bResult = true;
var_sKey_Code = event.keyCode;
if (var_sKey_Code == 86)
{ if (event.ctrlKey) var_bResult =
fun_mTextarea_P aste(prm_oTexta rea_Obj); }

if(prm_oTextare a_Obj.value.len gth >= prm_oTextarea_O bj.maxLen)
{ var_bResult = false;

if (var_oTextarea_ TxtRng.queryCom mandState('Over Write') &&
(prm_oTextarea_ Obj.value.lengt h == prm_oTextarea_O bj.maxLen))
{ var_bResult = true; }
else
{
for (i=0; i<var_aKey_Spec ial.length; i++)
{ if (var_sKey_Code == var_aKey_Specia l[i]) {var_bResult = true;
break;} }
}
}

return var_bResult;
}

function fun_mTextarea_P aste(prm_oTexta rea_Obj)
{ var var_sClipboard_ Text;
var_sClipboard_ Text = window.clipboar dData.getData(" Text");
prm_oTextarea_O bj.TxtRng =
document.select ion.createRange ().duplicate();

if (prm_oTextarea_ Obj.TxtRng && prm_oTextarea_O bj.createTextRa nge)
{ prm_oTextarea_O bj.TxtRng.text =
prm_oTextarea_O bj.TxtRng.text. charAt(prm_oTex tarea_Obj.TxtRn g.text.length
- 1) == ' ' ? var_sClipboard_ Text + ' ' : var_sClipboard_ Text;
}
else
{ prm_oTextarea_O bj.TxtRng.text = var_sClipboard_ Text;}

prm_oTextarea_O bj.value = prm_oTextarea_O bj.value.substr ing(0,
prm_oTextarea_O bj.maxLen);
return false;
}

</SCRIPT>
</HEAD>
<BODY>
<textarea maxLen=10 onkeydown="retu rn
fun_pTextarea_M axLen(this);"></textarea>
</BODY>
</HTML>
(ref:phoenix398 017)

"RSB" <rs*****@hotmai l.com> wrote in message news:<T2******* *********@news. cpqcorp.net>...
Hi Guys..
its me again.. ;o))

now i have a TextBox with properties Textmode = singleline and MaxLength =
100. So this works fine and i cannot enter more then 100 Chars. But as soon
as i change the TextMode to MultiLIne the MaxLength gets ignore as it is
painted as TEXTAREA. so how do i add a validator control to make sure that
user is not entering more than 100 Characters..

Thank you for the help in advance.

RSB.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4051
by: Joel Finkel | last post by:
Folks, I have a form that has several TextBoxes, some of which have the TextMode set to MultiLine. Each is pre-loaded with data from a database. The user is allowed to modify each entry. The problem is that only the modified data from the SingleLine TextBoxes are returned. The original data are returned for the MultiLine TextBoxes. Also, if the page is sent to the server (for validation, for instance), only the modified data for the...
2
2496
by: Enzo Marinelli | last post by:
Hello everyone I have a MultiLine TextBox, as follows <asp:TextBo Id="StreetAddress Rows="4 Runat="Server TextMode="MultiLine Width="100%"/
1
1130
by: Miguel Dias Moura | last post by:
Hello, i added an ASP.Net input text form in a page: <td> <asp:TextBox ID="CV" Rows="15" runat="server" TextMode="MultiLine" Columns="66" ToolTip="Insert your CV" MaxLength="2000" /> </td> I wanted to set a limit of 2000 chars. I inserted MaxLength="2000" in my
0
1681
by: the friendly display name | last post by:
Hi, I have a filled multiline textbox on the site. I can scroll it with IE and Firefox, but under Opera (tested under 7.54, and Opera 8, under "identify as MSIE" and under Opera identification) , I'm getting a strange behavior: When I try to scroll, the text doesn't move. It only moves to a new position, if I move the scroll marks, and then click on a empty place of the website. There is nothing on the site, just the textbox.
1
1737
by: jason | last post by:
I've seen a few posts on this issue, but no clear solutions. I have a mulitiline textbox inside a datagrid. I use TemplateColumn to define as multiline with 3 rows. I have other field types like drop downs that have no issue displaying last values in edit mode with seemingly more complicated code. when I attempt to find my textbox with
1
2120
by: Jeff | last post by:
hey asp.net 2.0 I'm trying to create a web page where users can register to my web portal. But I've run into a layout problem when using the data validator classes. The problem is that the error message is not displayed on the same row as the control it's validating. Check this link and you see an example of the problem: http://home.online.no/~au-holme/pub/14506/problem.GIF the text "Password and confirm password must match" is not...
0
1580
by: dancer | last post by:
Can somebody tell me why my RequiredFieldValidator works for the TEXT BOX, (location) but does NOT work for the RADIO BUTTON (EmpTrain)? <%@ Page Language="VB" ClientTarget="downlevel" %> <%@ Import Namespace="System.Web.Mail" %> <script language="VB" runat="server">
2
5830
by: Nathan Sokalski | last post by:
I have a multiline TextBox that I want to display the text used to create a control in an apsx file. I want each of these to be on a separate line in the TextBox. The only way I know of to place things on separate lines in a TextBox without doing it programmatically is the following: <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine"> Line 1 Line 2 Line 3 </asp:TextBox>
2
3280
by: s2008 | last post by:
Hello, In my page i have two textboxes and a html button. I'm using vb.net 2.0 . what i need is i want whatever text selected in the textbox1 to be hyperlinked when clicked the button... this is no problem.. i'm getting it easily.. But my problem is , if i select some text from the textbox2 and click the button it is also hyperlinked. i want only whatever text selected in the textbox1 to be hyperlnked and not in textbox2. Please tell me how...
0
9566
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9946
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8830
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7371
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6646
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5272
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5413
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.