Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
chop

When Reading Data Into A Text Field From A Db, Safari Does Not Ignore White Space

Recommended Posts

Here's the code to read in a date from a db. The date itself, from the db table, contains no white space:

 

Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value="<?php echo $row['dateCreated'] ?>"  /> yyyy-mm-dd<br />

 

 

If I go into my code and hit the return button after  value="  it looks like this:

 

Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value="

<?php echo $row['dateCreated'] ?>"  /> yyyy-mm-dd<br />

 

In Firefox, this has no effect a-as it should. However Safari will insert a space before the date value in the text field. This is a problem because the value for date within the form will not validate when it hits the space.

 

Even if I insert a trim() in the above line:

Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value="<?php echo trim($row['dateCreated']) ?>"  /> yyyy-mm-dd<br />

 

it still inserts a space.

 

I've never considered the arbitrary code formatting practice of hitting a return anywhere I want. Has anyone else run into this?

 

 

Share this post


Link to post
Share on other sites

I don't really understand the point here. You said:

If I go into my code and hit the return button after value="

How about you don't do that? YOU are the one introducing the extra space within the value attribute. This isn't a user issue and it doesn't really matter what the different browsers do. Just don't do that. This is an entirely solvable and controllable problem.

Share this post


Link to post
Share on other sites

Sorry. It's not that I couldn't get it to work after taking out the returns in my code. I was just curious because I tend to enter returns in Dreamweaver code view to break lines into a more visually understandable format. I never knew it could cause a problem.

 

I will withdraw the question.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...