Posts

Showing posts with the label javascript

TrustButVerify - simple jQuery validation powered by LiveValidation

I really like the way LiveValidation runs; however, I REALLY LOVE jQuery selectors & chaining. Unfortunately the LiveValidation approach to validation doesn't feel right when looking at a lot of field-specific validators surrounded by super terse jQuery syntax. So I decided to make a small 79-line wrapper-type of plugin that is powered by LiveValidation but comes with all the power of jQuery's selectors, chaining and... well, jQuery. I called the plugin, TrustButVerify . Check it out & let me know your thoughts or if there is room for improvement (which there definitely is). I have NOT exposed all of the LiveValidation methods; just the ones I found useful & necessary :-p Here's a sample of some validation: $(document).ready(function(){ $('#form .required').required(); $('#email').validEmail(); $('#zip').matches(/^\d{5}$/); $('input.address').required().validate(someCustomFunction, 'your address is out of our area ...

Syntax Highlighting in Blogger -- with jQuery & SyntaxHighlighter

There are a few reasons I decided to go with Blogger over other blogging options. 1) I want to spend time writing not setting things up, 2) BlogEngine.NET didn't seem to look right no matter what theme I used and I didn't like the admin and 3) Wordpress is all MySQL. That being said I wanted to get SyntaxHighlighter working. After reading Guogang Hu's post about how to get it working (& not likely a lot of code), I decided to do it with jQuery. The real issue with SyntaxHighligher and Blogger is the line breaks. Posts have line breaks replaced by <br /> tags -- which SyntaxHighlighter will faithful display. Using the replaceWith method in jQuery makes this a snap. Check out the code below. <link href='/syntaxhighlighter/styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'></script> <sc...