473,388 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

DATE and TEXTAREA question

hello all,

am new to HTML and am in the process of creating a form, no serious
headaches, but am stumped on two types of fields. i can take care of these
situations using javascript, but was adviced to only use javascript only
when absolutely necessary, so am trying to find to see if i can handle these
situations in HTML only.
TEXTAREA field
maxlength isn't doing anything, is there a solution?

DATE
is there a way to create a DATE field that only accepts numbers and "/". i
have found tons of sites that say input="date" or date="mm/dd/yyyy", but
they do nothing!

if in the end i have to do all my validating via javascript or server side,
so be it, but wanted to check out here first.

many thanks ahead of time,

daniel
Jul 23 '05 #1
7 3727
daniel kaplan wrote:
am new to HTML and am in the process of creating a form, no serious
While writing words entirely in capital letters is an accepted form of
emphasis, they should also be used to start sentences. It makes it rather
harder to read a message which lacks capitals in the usual places, so
please help us to help you.
headaches, but am stumped on two types of fields. i can take care of
these situations using javascript, but was adviced to only use javascript
only when absolutely necessary
JavaScript is not something that should be used only when there is no other
way. It can be used for many things, but should never be _depended_ upon
(and generally shouldn't be used when the effect can be achieved in plain
HTML 4.01 Strict or CSS).
TEXTAREA field
maxlength isn't doing anything, is there a solution? DATE
is there a way to create a DATE field that only accepts numbers and "/".


There is nothing in HTML to enforce the format of text entered into a
textarea field, nor is there anything to suggest a maximum length of a
textarea. JavaScript could be used in both these cases to aid the user in
entering data to fit the requirements of the system.

Even the HTML suggestions are only suggestions, there is nothing actively
preventing the user from entering whatever data they like - so you should
*always* perform sanity checking of incoming data on the server.

On the subject of the date, my preferred method for handling this type of
thing is a normal text input for the user to enter the date. Next to this I
(having checked that the browser supports enough JavaScript, CSS and DOM to
handle it) I place a calendar icon set to fire off a JSCalendar[1] which
writes the date out in an unambiguous format[2]. On the server I then run
the date through Date::Parse[3] which can cope with most date formats a
user might choose to use.

[1] http://www.dynarch.com/projects/calendar/
[2] e.g. 12th Dec 2004
[3] http://search.cpan.org/~gbarr/TimeDa.../Date/Parse.pm

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #2
On Sun, 12 Dec 2004 17:10:24 -0500, daniel kaplan <no****@nospam.com>
wrote:

[snip]
i can take care of these situations using javascript, but was
adviced to only use javascript only when absolutely necessary,
You can use client-side scripting as often as you like. The caveat is that
you must not *rely* on it (at least on the Web) to perform validation or
provide critical functionality (like navigation). You can use Javascript
to validate a form, but that validation should be replicated on the server.

[snip]
TEXTAREA field
maxlength isn't doing anything, is there a solution?
There is no maxlength attribute for TEXTAREA elements. You'll have to
check the length of the string on submission.
DATE
is there a way to create a DATE field that only accepts numbers and "/".
No.
i have found tons of sites that say input="date" or date="mm/dd/yyyy",
but they do nothing!


Then tons of sites contain complete rubbish (nothing unusual there, then).
:) Again, it's something you'll have to validate yourself, though be
careful with using locale-specific date formats if you'll draw audiences
from other countries.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
"David Dorward" <do*****@yahoo.com> wrote in message
news:cp*******************@news.demon.co.uk...

[many things]

Thanks for your help, if i may ask a follow up:

Woudl it be wiser to use BOTH JS and server-side to validate the data? I
mean sure, I could use JS to do that, but then wiseguys (i assume) could
manipulte outgoing data, and then lets face it, not validating at the server
side would just be crazy.

So my thoughts are, validate at the client-side (using JS) to elminate 95%
of server-side processing time, by catching innocent mistakes, and then
still validate at server-side to prevent the trouble makers.

Woudl my thinking be correct here?

Thanks agaiun,

daniel
Jul 23 '05 #4
daniel kaplan wrote:
Woudl it be wiser to use BOTH JS and server-side to validate the data?


I thought I've covered this in my previous post, but rereading it I find
that I only implied it, so here goes:

If its important the the data you receive fit a certain format (and it very
often is, even if only to avoid losing data that won't fit in the given
space in a database column) then you *should* perform some form of check on
the server and return an error message (or maybe just a wanring) to the
user if it fails.

*Optionally*, after[1] you have written the server side code, you can look
at providing some client side check (using the maxlength attribute and/or
JavaScript) as a *convenience* to the user so that they can receive the
afore mentioned error or warning without having to spend time watching
their form submission make a round trip to the server and come back with
errors.

[1] You could do it before, but leaving it until after helps avoid lazyness
and accidently dependency on the client side code.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #5
On Sun, 12 Dec 2004, Michael Winter wrote:
You can use Javascript to validate a form,
agreed, but as you say, there's no certainty it'll get executed
but that validation should be replicated on the server.
Oh, I'd put it stronger than that. Any form which does something of
any significance *must* get its input validated on the server. It
would be insane to miss that out.

But that's a topic for itself (c.i.w.a.cgi would be the usual
recommendation - beware the automoderator bot) and not really
something that should be discussed in any depth here on *.html
i have found tons of sites that say input="date" or
date="mm/dd/yyyy", but they do nothing!


You'd be in luck today...
Again, it's something you'll have to validate yourself, though be
careful with using locale-specific date formats if you'll draw
audiences from other countries.


Absolutely!

Jul 23 '05 #6
On Sun, 12 Dec 2004 17:10:24 -0500, "daniel kaplan" <no****@nospam.com>
wrote:
am new to HTML and am in the process of creating a form, no serious
headaches, but am stumped on two types of fields. i can take care of these
situations using javascript, but was adviced to only use javascript only
when absolutely necessary, so am trying to find to see if i can handle these
situations in HTML only.


You may find this helpful:
http://www.xs4all.nl/~sbpoley/webmatters/formval.html

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 23 '05 #7
JRS: In article <Pi*******************************@ppepc56.ph.gla. ac.uk
, dated Sun, 12 Dec 2004 23:50:26, seen in news:comp.infosystems.www.au thoring.html, Alan J. Flavell <fl*****@ph.gla.ac.uk> posted :On Sun, 12 Dec 2004, Michael Winter wrote:
You can use Javascript to validate a form,


agreed, but as you say, there's no certainty it'll get executed
but that validation should be replicated on the server.


Oh, I'd put it stronger than that. Any form which does something of
any significance *must* get its input validated on the server. It
would be insane to miss that out.


Only if there is a server that accepts form input; and if any possible
response from the form could inconvenience the proprietor of the
service.

My host offers only a few pre-programmed responses; but, if it did allow
me to write server-side processing, I would not want to look at the
results; my only concern would be that there could be nothing resembling
a Denial-of-Service attack. If a user were to choose to submit garbage,
then he would get garbage back.

Of course, you may say that my pages should not be using forms. They
were recommended to me as a means, in effect, of scoping HTML
identifiers; please feel free to explain anything that would be better.
But at present they are forms.

I'm reasonably sure that Michael meant that, for data with external
effect server-side, reliance on client validation is inadequate; and
that input must be validated by receiving-system code whenever validity
matters to the receiver.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #8

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

Similar topics

1
by: Thomas S. | last post by:
Hello I´ve got a question concerning the usage of a textarea in a xsl. When i just write the following code, <span style="font-size:12.0pt; "><textarea name="hotelbeschreibung" rows="5"...
4
by: Csaba Gabor | last post by:
What I'd like to do is to be able to set the font of a textarea element to the same font that another element is using (say, for example, an <INPUT type=text ...> element, but if that's a no go,...
26
by: sgershon | last post by:
Hi. I know this is should be a simple question. I know server-side web-programming, and never needed to use client-side scripting... until now :) I have done so far a little number of scripts...
8
by: Mark D. Smith | last post by:
Hi I have googled but not found a solution to wordwrap in a textarea using firefox/netscape. is there a style sheet solution or am i stuck with not being able to force wrapping in a textarea...
16
by: Jen | last post by:
Hi. I have this problem that I think should be easy but have been struggling with this for days. I have a list based on a recordset from a database. This list consists of records meeting a certain...
1
by: cabbiepete | last post by:
In the thread http://www.thescripts.com/forum/thread11792.html this question was posed and while an answer was posted it wasn't explained at all why that worked. I thought I would post the answer in...
0
by: saijin | last post by:
I'm planning to call a list of data from an XML file but when I duplicate the content inside the <data></data> it is not showing anything Here's the ActionScript 3.0 import...
10
by: agun | last post by:
Hello, question 1: how do i get textarea value to javascript variable if the textarea contains linefeed? it only works if the textarea contains no linefeed. var jtext =...
7
by: Totti | last post by:
Hi all, I am a newbie to javascript learning it for 2 months now, i am trying to make a sorter who will read english words from the one tex area or data file and show the result in the 2nd text...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
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,...
0
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...

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.