chop Posted August 22, 2013 Share Posted August 22, 2013 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? Link to comment Share on other sites More sharing options...
Antonio Conte Posted August 22, 2013 Share Posted August 22, 2013 Trim the post data upon validation too. Link to comment Share on other sites More sharing options...
chop Posted August 22, 2013 Author Share Posted August 22, 2013 I already do that. The db table dates do not contain white space. Link to comment Share on other sites More sharing options...
Larry Posted August 23, 2013 Share Posted August 23, 2013 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. Link to comment Share on other sites More sharing options...
StephenM Posted August 23, 2013 Share Posted August 23, 2013 can you post your validation section for the $_POST['datecreated'] value? Link to comment Share on other sites More sharing options...
chop Posted August 26, 2013 Author Share Posted August 26, 2013 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. Link to comment Share on other sites More sharing options...
Recommended Posts