Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Minlength and Maxlength

Reply
Thread Tools

Minlength and Maxlength

 
 
Luigi Donatello Asero
Guest
Posts: n/a
 
      02-13-2005
In html there is an attribute which is called maxlength which let you
prevent the user to write more than a certain number of characters in a
form.
There is no attribute such as minlength.
Does that mean that the only way
to prevent the user to write less than a certain number of characters is to
code it
in php or some other computer language which let me create a dynamic page
or do you also have a html option?




--
Luigi ( un italiano che vive in Svezia)
https://www.scaiecat-spa-gigi.com/sv...italienska.php





 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      02-13-2005
Luigi Donatello Asero wrote:

> In html there is an attribute which is called maxlength which let you
> prevent the user to write more than a certain number of characters in a
> form.
> There is no attribute such as minlength.


There is no HTML technique to suggest prevent a form being submitted if the
user doesn't enter data in a specific form. You could use JavaScript to do
some form of checking when the onsubmit event of the <form> fires -
returning false will halt the submission.

JavaScript is, of course, optional, so you can not depend on it catching
data which doesn't conform to your needs. For that matter, there is nothing
stopping the user from overriding any maxlength you specify for any input.

The only place you can perform sanity checking on the data and be certain
that the checking has been triggered is within the form processor on the
server.


--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
 
Luigi Donatello Asero
Guest
Posts: n/a
 
      02-13-2005

"David Dorward" <> skrev i meddelandet
news:cunn5j$1po$1$...
> Luigi Donatello Asero wrote:
>
> > In html there is an attribute which is called maxlength which let you
> > prevent the user to write more than a certain number of characters in a
> > form.
> > There is no attribute such as minlength.

>
> There is no HTML technique to suggest prevent a form being submitted if

the
> user doesn't enter data in a specific form. You could use JavaScript to do
> some form of checking when the onsubmit event of the <form> fires -
> returning false will halt the submission.
>
> JavaScript is, of course, optional, so you can not depend on it catching
> data which doesn't conform to your needs. For that matter, there is

nothing
> stopping the user from overriding any maxlength you specify for any input.
>
> The only place you can perform sanity checking on the data and be certain
> that the checking has been triggered is within the form processor on the
> server.


So, for example by using php and declaring by an "if clause"
that a variable is accepted as long it is "<" (lower)
than a certain number.


--
Luigi ( un italiano che vive in Svezia)
https://www.scaiecat-spa-gigi.com/sv...eiitalien.html












 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      02-13-2005
Luigi Donatello Asero wrote:

> There is no attribute such as minlength.
> Does that mean that the only way to prevent the user to write less than
> a certain number of characters is to code it in php or some other
> computer language which let me create a dynamic page or do you also
> have a html option?


Browsers can happily ignore maxlength, so if length is important to
yout you *must* enforce the length limit at the server side.

If you want a client-side minimum length, you could use Javascript, but
make sure you back it up with a server-side check.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      02-13-2005
Toby Inkster <> wrote:

> Browsers can happily ignore maxlength, so if length is important to
> yout you *must* enforce the length limit at the server side.


The conclusion is correct, but I disagree about the premises. The maxlength
attribute is defined as imposing a limit on the amount of text entered in a
text input field. It very much looks like browsers are required to
implement that limit, and that they actually do so.

But nothing prevents a user from copying a form and editing it, so that the
maxlength attribute is changed or removed, or writing a completely
different form with the same action attribute. This could happen out of
malevolence or cracking attempt, or through an attempt to create a
"customized form" (e.g. for personal use) plus some technical error in
doing that. In any case, such possibilities are a fundamental reason for
making form data handling robust - it should be prepared to literally
anything, including data that cannot result from submitting the form!

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      02-13-2005
Jukka K. Korpela wrote:
> Toby Inkster <> wrote:
>
>> Browsers can happily ignore maxlength, so if length is important to
>> you you *must* enforce the length limit at the server side.

>
> The conclusion is correct, but I disagree about the premises. The
> maxlength attribute is defined as imposing a limit on the amount of text
> entered in a text input field. It very much looks like browsers are
> required to implement that limit, and that they actually do so.


"can" = "are able to"
"may" = "are allowed to"

Browsers *can* happily ignore maxlength.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Luigi Donatello Asero
Guest
Posts: n/a
 
      02-14-2005

Do HSDPA´s users
have access to html pages?
What about pages using php, asp and other programming languages?
Or would you write pages in WAP also for
HSDPA´s users?

--
Luigi ( un italiano che vive in Svezia)
https://www.scaiecat-spa-gigi.com/de...-sizilien.html





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
maxlength on multiline textbox hardcoded ASP .Net 5 09-26-2007 05:36 PM
How can i read MaxLength properrty in a JavaScript CustomValidator function Patrice ASP .Net 3 06-11-2004 04:56 PM
TextBox - MaxLength property =?Utf-8?B?bWc=?= ASP .Net 1 04-11-2004 02:29 PM
Textbox maxlength..... Why doesnt that ever work??? Darren Clark ASP .Net 1 04-10-2004 02:56 AM
hexBinary minLength Bug or Feature? Don Adams XML 1 03-01-2004 09:57 PM



Advertisments