Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 22nd, 2003, 03:47 AM
rvw rvw is offline
Registered User
 
Join Date: Oct 2003
Location: , , .
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.


Reply With Quote
  #2 (permalink)  
Old October 22nd, 2003, 04:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
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
Reply With Quote
  #3 (permalink)  
Old October 22nd, 2003, 05:02 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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.
Reply With Quote
  #4 (permalink)  
Old October 22nd, 2003, 05:03 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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
Reply With Quote
  #5 (permalink)  
Old October 22nd, 2003, 05:40 AM
rvw rvw is offline
Registered User
 
Join Date: Oct 2003
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:17 PM.


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