Page 1 of 1

beyond html

Posted: Fri Aug 07, 2009 12:42 pm
by ConvertFromOldNGs
by rob >> Thu, 21 Oct 2004 20:46:29 GMT

Standard html does not appear to support the readOnly attribute on radio buttons, or allow textbox entry to be restricted to numeric only. Can any html/javascript gurus suggest ways to emulate this behaviour on a web page?

Thanks,
Rob

Re: beyond html

Posted: Fri Aug 07, 2009 12:42 pm
by ConvertFromOldNGs
by allistar >> Sat, 23 Oct 2004 3:45:06 GMT

Read only radio buttons could be simulated using an image, but the problem is you don't know how the client OS/browser will render radio buttons, so yo ucan't guarantee it will like like standard radio buttons. You could alwaysflip the selection of the radio button when the user clicks it by using javascript. Similarly with numeric only entry on text boxes. The problem with javascript solutions is that it only works if the client has javascript enabled.

Allistar.
--
------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------

Re: beyond html

Posted: Fri Aug 07, 2009 12:42 pm
by ConvertFromOldNGs
by Stephen >> Mon, 1 Nov 2004 3:31:03 GMT

For teh radio buttons, just set disabled=true
Eg <input type="radio" name="favouritefood" value="greeneggs" disabled="true">Green Eggs and Ham

For the numeric only textbox, it can only be done using javascript. Put a method on the "onBlur" (lost focus) that checks if the numeric value of the text = the actual text.
Eg.
<textarea id="favouritenumber" onblur="if(parseFloat(this.value) != this.value) alert('Numbers only please...')"></textarea>

Re: beyond html

Posted: Fri Aug 07, 2009 12:42 pm
by ConvertFromOldNGs
by rob >> Tue, 2 Nov 2004 2:09:39 GMT

Stephen, much appreciated ...
Rob