Jump to content

Setting a minimum length or something similar


cpd

Recommended Posts

HTML has a "maxlength" attribute you should look into.

 

If you don't want the user to be able to change it at all, an input is perhaps not the best way to go. You could setup a bit of JavaScript on the element though to make it default back to a value when the user loosees focus on the input (onblur):

 

<input (...) onblur="this.value='EUF';" />

If you don't want the user to change the value from "EUF" at all, perhaps you shouldn't be using an input..?

 

If the input's there for some design reasoning, perhaps use the disabled attribute, or, you could use a hidden input and just write the text "EUF" normally?

I agree with the last. Just put EUF as text just before the input field, so the user knows to enter the EUF code without the EUF text. Then add EUF to the input on the server-side before you use it.

 

Something like:

EUF<input type="text" name="EUFCode" />

If you want it to look as if it's in the input field you could a big left padding on the input and position absolute for positioning the text over it. HTML forms do not (yet?) allow masked textboxes like those found in programming languages.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.