The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Opinion: using JavaScript to style forms

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #24737

    Lets say you’re developing a rather large web application with lots of forms. What do you think about using JavaScript to set the proper classes for styling these forms instead of marking them up with the styles embedded? Let’s also assume, for the sake of argument, that JavaScript is already required for the web app to function properly.

    The idea is that a formStyling.js could be included that would scan all the necessary form elements when the document is ready and apply the styles appropriately. This way, you don’t need any additional markup on the form elements (like applying a "text" class to text inputs, etc., etc.). Also, you’d be able to change the actual name of the class or how and when the classes are applied from a central location; otherwise, when the name of a class or when it gets applied changes you’d have to change every instance throughout your application.

    So, what do you all think about this approach? I’m sure there are drawbacks. Just a little discussion.

    Chris Coyier

    The key sentence was that JavaScript is required for the app to function properly.

    Generally requiring JavaScript to make forms work is frowned upon, since users without it (by choice or not), shouldn’t be discriminated against by not being able to use a site. But… if this is A) merely aesthetic and B) would be broken anyway, I’d say go for it.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.