Skip to content

Instantly share code, notes, and snippets.

@orlin
Created February 4, 2011 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orlin/811713 to your computer and use it in GitHub Desktop.
Save orlin/811713 to your computer and use it in GitHub Desktop.
trying get going with happy.js validation
$(document).ready ->
$('#enlist').iphoneStyle
checkedLabel: 'For Sure'
uncheckedLabel: 'No Thanks'
resizeContainer: false
resizeHandle: false
$('input[type="text"]:first').focus()
# happy validation here
$('#contact_form').isHappy
fields:
'#name':
required: true
message: "May we ask for a name?"
'#email':
required: true
message: "The email where we can contact you, please. It's safe, promise."
$(document).ready(function() {
$('#enlist').iphoneStyle({
checkedLabel: 'For Sure',
uncheckedLabel: 'No Thanks',
resizeContainer: false,
resizeHandle: false
});
$('input[type="text"]:first').focus();
return $('#contact_form').isHappy({
fields: {
'#name': {
required: true,
message: "May we ask for a name?"
},
'#email': {
required: true,
message: "The email where we can contact you, please. It's safe, promise."
}
}
});
});
@HenrikJoreteg
Copy link

Line 11, the id isn't #first it's #name.

Also, happy.js will deal with stopping the form from submitting if there's errors so just get rid of lines 21,22,23.

Also, there was a bug when i first published it, so make sure to grab the latest version just to be safe.

@orlin
Copy link
Author

orlin commented Feb 5, 2011

Thanks for spotting it. This #id was one stubborn hallucination :) The form is happy now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment