I need to validate my TextArea as follows:
1) IT SHOULD ALLOW FOR ONLY 5 COLUMNS
2) IT SHOULD ALLOW ONLY 65 CHARACTERS PER ROW
I need some kind of a JS validation for the same. I have tried using hard wrap
but that doesnt help completely.
Any help in this matter would be very much appreciated!
Thanks!
S Kulkarni 3 32418 ku********@hotm ail.com (Sunil Kulkarni) writes: I need to validate my TextArea as follows:
1) IT SHOULD ALLOW FOR ONLY 5 COLUMNS
I assume you mean rows :)
2) IT SHOULD ALLOW ONLY 65 CHARACTERS PER ROW
I need some kind of a JS validation for the same. I have tried using hard wrap but that doesnt help completely.
A regular expression should be able to match zero to five lines of
zero to 65 characters, if you define the lines to be separated by
newlines ("\n").
If you want to look at automatic line wrapping, and count lines as
they are displayed, it gets ugly fast, but with some assumptions,
it should be manageable.
So, let's define a line to be up to 65 characters followed by a
newline characters, or just 65 characters followed by a newline, and
we want to check that a string contains at most 5 lines.
The final line can be up to 65 characters without being followed by a
newline.
A suitable regular expression is:
/^(.{0,65}\n|.{6 5}){0,4}.{0,65} \n?$/
However, the input of a textarea might not use a single character for
newlines. Both Opera and IE ends their lines with "\x0d\x0a"
(Carrige Return + newline, DOS EOL), where Mozilla uses "\x0a" (Just
newline, Typical Unix EOL). Maybe Macintosh browsers use "\x0d\x0a",
as that is the typical Apple (and Amiga) EOL sequence.
Anyway, the above RegExp won't work in Opera and IE, since "\x0d\x0a"
is two newline characters. The solution I can see, is to replace those
with a single newline first:
string.replace(/(\x0a\x0d|\x0d\ x0a)/g,"\n");
Then test with the above RegExp.
Any help in this matter would be very much appreciated!
Hope this helps.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Sunil Kulkarni wrote: I need to validate my TextArea as follows:
1) IT SHOULD ALLOW FOR ONLY 5 COLUMNS 2) IT SHOULD ALLOW ONLY 65 CHARACTERS PER ROW
I need some kind of a JS validation for the same. I have tried using hard wrap but that doesnt help completely.
Any help in this matter would be very much appreciated! Thanks! S Kulkarni
What's wrong with:
<form action="">
<p><textarea name="TextareaN ame" rows="5" cols="65"
wrap="soft"></textarea></p>
</form>
The string submitted can later be rendered within a textarea with the
same (or other) cols and rows attribute values.
On the wrap attribute, MSDN http://msdn.microsoft.com/workshop/a...rties/wrap.asp
says:
soft: Default. Text is displayed with wordwrapping and submitted without
carriage returns and line feeds.
hard: Text is displayed with wordwrapping and submitted with soft
returns and line feeds.
off: Wordwrapping is disabled. The lines appear exactly as the user
types them.
DU
--
Javascript and Browser bugs: http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x http://www10.brinkster.com/doctorunc...e7Section.html
Thankyou very much for the suggestions!
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote in message news:<ll******* ***@hotpop.com> ... ku********@hotm ail.com (Sunil Kulkarni) writes:
I need to validate my TextArea as follows:
1) IT SHOULD ALLOW FOR ONLY 5 COLUMNS
I assume you mean rows :)
2) IT SHOULD ALLOW ONLY 65 CHARACTERS PER ROW
I need some kind of a JS validation for the same. I have tried using hard wrap but that doesnt help completely.
A regular expression should be able to match zero to five lines of zero to 65 characters, if you define the lines to be separated by newlines ("\n").
If you want to look at automatic line wrapping, and count lines as they are displayed, it gets ugly fast, but with some assumptions, it should be manageable.
So, let's define a line to be up to 65 characters followed by a newline characters, or just 65 characters followed by a newline, and we want to check that a string contains at most 5 lines.
The final line can be up to 65 characters without being followed by a newline.
A suitable regular expression is: /^(.{0,65}\n|.{6 5}){0,4}.{0,65} \n?$/
However, the input of a textarea might not use a single character for newlines. Both Opera and IE ends their lines with "\x0d\x0a" (Carrige Return + newline, DOS EOL), where Mozilla uses "\x0a" (Just newline, Typical Unix EOL). Maybe Macintosh browsers use "\x0d\x0a", as that is the typical Apple (and Amiga) EOL sequence.
Anyway, the above RegExp won't work in Opera and IE, since "\x0d\x0a" is two newline characters. The solution I can see, is to replace those with a single newline first:
string.replace(/(\x0a\x0d|\x0d\ x0a)/g,"\n");
Then test with the above RegExp.
Any help in this matter would be very much appreciated!
Hope this helps. /L This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: EviL KerneL |
last post by:
Hi -
I am trying to figure out a way to enforce the validation included for
this form based on whether the user chooses "email" or "phone" as the
contact choice. Right now it is set to enforce validation on both.
Is there a way to link the drop-down choice to the correspondent
validation section while disabling validation for the other one?
here's what I presently have:
|
by: ianv2 |
last post by:
Hi
I have the following form that I need advanced validation on, I would
appreciate any help please.
How can I validate the form so that the user has to select an option
from the select box and if they choose 'other' the focus goes to the
'otherfeedback' textarea which also has to have a value.
<form action="feedback.cfm" method="post" name="form" id="Form"
|
by: Chris |
last post by:
Hi,
I have a form for uploading documents and inserting the data into a mysql
db. I would like to validate the form. I have tried a couple of Javascript
form validation functions, but it appears that the data goes straight to the
processing page, rather than the javascript seeing if data is missing and
popping up an alert. I thought it may be because much of the form is
populated with data from the db (lists, etc.), but when I leave...
|
by: Rik |
last post by:
Hello guys,
now that I'm that I'm working on my first major 'open' forms (with
uncontrolled users I mean, not a secure backend-interface), I'd like to add
a lot of possibilities to check wether certain fields match certain
criteria, and inform the user in different ways when the data is wrong
(offcourse, this will be checked on posting the data again, but that's
something I've got a lot of experience with).
Now, offcourse it's...
|
by: Paul |
last post by:
I normally use HTML_Quickform but new client's server doesn't have it and
can't get it (ipowerweb.com). So I am reverting back to my beginnings and
have forgotten how to validate forms easily.
If you know of any links to classes or files (yes, I have already searched
google) that you like and are EASY to use/implement, please post them or
links to them.
Many thanks!
| |
by: Andrew Poulos |
last post by:
I'm dynamically populating a TEXTAREA with some info that includes a
URL. Eg.
frm.value = "This is the link to use <url: http://www.foo.com >";
but this results in a page that doesn't validate. I tried escaping the
value but then I get entities displaying in the TEXTAREA.
Is there a way to change the value without upsetting the page's validation?
|
by: karen987 |
last post by:
I have a comment form, on a news website, ASP page, which users fill in and it adds comments to a news article. The reader clicks on a headline and the comments open up in a new window. It already has server side validation in but i want to add some client side javascript validation. How can do i this when there is alreay a "returnvalidate comment()" in? The only two fields i want to validate are "subject" and "comment" since the rest are drawn...
|
by: pradeepjain |
last post by:
Hii,
I want to check for empty textarea with javascript ..say only blank space must also be treated as empty textarea...how to do it..is there any script for this .
|
by: maxamis4 |
last post by:
I currently have an input form in HTML. I am trying to use JavaScript to validate that the html forms are entered. I had it working earlier today but now my form is not validating. Could someone take a look and tell me why its not working.
php html page
<?php
require_once('auth.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html...
|
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...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |