Question

I have 3 sets of 4 input fields that I want the user to complete and submit to my site. Fields are optional. I have an $all variable that I am storing the data inside.

However, if any input fields aren't completed, then I'd like to remove the placeholder text from the $all variable.

Currently my output (var_dump) for completing the first row is:

string '1|1|1|1

Height (cm)|Width (cm)|Length (cm)|Weight (kg)

Height (cm)|Width (cm)|Length (cm)|

' (length=133)

However, I'd like it to be:

string '1|1|1|1' (length=7)

Here is my current code on Pastebin: http://pastebin.com/2Je75vN0

As you can see, placeholder text is placed inside the field using javascript and the title attribute.

Can a very nice and gifted person please point me in the right direction with this? Or should I perhaps be using Javascript to validate this?

Many thanks for any pointers.

Was it helpful?

Solution

Consider using HTML5's placeholder= attribute (with a JavaScript fallback for older browser).

It's inefficient and it doesn't make sense to handle placeholders on the server side.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top