3

I am working on various projects for my organization that were started by another developer. A good portion of this work involves form processing with PHP.

I was rather surprised to see that for many of the form values, the previous developer used spaces (for example <input type="radio" value="DO NOT ENROLL" name="proceed" /> ). I think I know why he did it - he sends it as it email and makes it easy to display the values in a human readable format without additional processing, but, as someone who is used to 'typical' programming naming conventions (no spaces, camel case, pascal case, and so on), this does make me a little uneasy. Whenever I have processed HTML forms and assigned values, I believe I always tried to following "typical" variable naming conventions, but this could have habit rather than a necessary practice.

Now, I am not saying he is wrong, but I tried to do a little research on the topic and have not reached a definite conclusion. So my question is this - is there anything wrong with including spaces in values assigned to HTML form input elements - particularly when it will be sent over email? If so, what complications may result, and is there a way to properly process them, or would you recommend keeping the actual form values simple (for example, <input type="radio" value="decline" name="proceed" /> and THEN processing them to make them more readable after the form is submitted.

Thanks for any input!

2
  • I would defenitely lose the additional spaces... source for errors, typos, ... Commented May 28, 2016 at 16:15
  • 2
    Spaces inside values for inputs is very common. It are values after all, not names. What about a text type input, or even a textarea? I can't think of any good reason not to use spaces inside values... Commented May 28, 2016 at 16:52

2 Answers 2

5

There is nothing bad, except the only real restriction on what characters can appear in form control names is when a form is submitted with GET

"The "get" method restricts form data set values to ASCII characters.

Source 1 | Source 2

Sign up to request clarification or add additional context in comments.

2 Comments

I'm not sure if html4 references are still helpful.
They are still being used although not as popular as before. Not sure what about HTML5 parsing.
1

I would definitely change them to camel case, pascal case or whatever else closer to coding conventions/standards. It may work either way, but...better be safe than sorry.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.