Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save minikermit/534522 to your computer and use it in GitHub Desktop.
Save minikermit/534522 to your computer and use it in GitHub Desktop.
# application.helper
def default_text(text)
onClickFunction = "field = event.target; if (field.value=='#{text}') {field.value = '';}else {return false}"
onBlurFunction = "field = event.target; if (field.value=='') {field.value = '#{text}';}else {return false}"
{:value => text, :onclick => onClickFunction, :onblur => onBlurFunction}
end
# view
<%= text_field_tag 'login', @login , default_text("Login")%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment