Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

HenrikJoreteg commented Feb 5, 2011

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.

Loading

@orlin
Copy link
Author

orlin commented Feb 5, 2011

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

Loading

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