Created
February 4, 2011 20:34
-
-
Save orlin/811713 to your computer and use it in GitHub Desktop.
trying get going with happy.js validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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." | |
} | |
} | |
}); | |
}); |
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
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.