Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2003, 03:47 AM
rvw rvw is offline
Registered User
 
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Protect input-field from entering data

In a form I use a date-field with a calendar-popup-window, which enters the correct date-format into that date-field. I would like to protect the date-field, so users cannot enter data themselves. Anyone know how to do this? And preferrably not ie-only.


 
Old October 22nd, 2003, 04:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Forgive me if I am misunderstanding you, but could you not just use hidden input fields instead?

Dan
 
Old October 22nd, 2003, 05:02 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, for feedback purposes, it might be useful to show the displayed as well, no?

You can use the readonly attribute, like this:

<input type="text" readonly="readonly" value="Your Value" id="txtDate">

This way, a user can no longer change the text, but you can still access it with JavaScript.

Note that readonly is not supported on all browsers....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 22nd, 2003, 05:03 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Set readonly attribute:
Code:
<input type="text" READONLY>
In IE and maybe some newer Mozillas you can set DISABLED instead, there is a difference, you can focus on read only boxes.
or use a div or a span, if the data is submitted to another page use a hidden field as well.

--

Joe
 
Old October 22nd, 2003, 05:40 AM
rvw rvw is offline
Registered User
 
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Perfect! Readonly does exactly what I need. Thanks a lot!!!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Entering data into an SQL database jmsherry SQL Server 2000 3 July 24th, 2007 01:00 AM
VBA code for entering the same data for dates rohit_ghosh Access VBA 1 May 3rd, 2007 09:45 AM
entering Null value for Date field jordancrandall Access ASP 1 January 12th, 2005 01:29 PM
Entering data to dynamic table cells weebadbilly XSLT 0 June 30th, 2004 07:15 AM
entering data Kelly Johnson Classic ASP Databases 1 August 7th, 2003 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.