Skip to content

Instantly share code, notes, and snippets.

@csdy
Last active December 16, 2015 18:20
Show Gist options
  • Save csdy/5477178 to your computer and use it in GitHub Desktop.
Save csdy/5477178 to your computer and use it in GitHub Desktop.
jQuery validation with HTML5 browser validation fallback
<!-- jQuery -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/js/vendor/jquery-2.0.3.min.js"><\x3C/script>')</script>
<!-- jQuery Validate -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.11.1/jquery.validate.min.js"></script>
<script>window.jQuery.validator || document.write('<script src="/js/vendor/jquery.validate-1.11.1.min.js"><\x3C/script>')</script>
<script>
// DOM ready
$(function() {
// Check dependencies
if(window.jQuery && window.jQuery.validator) {
// Disable native validation
$('form').attr('novalidate', 'novalidate');
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment