0

My boss asked me to program a custom jQuery validation plugin. If <input /> tag has special attribute [needcheck], my plugin must determine the type of [needcheck] and check input data before submit.

For example:

<input name="email" type="text" needchek=”Email”/>

If value of <input /> tag has errors, plugin must show a promting message.

Available types for [needcheck]:

  • Date:[FORMATDATE] – date in format (For example Date:dd.MM.yyyy)
  • Time:[TIMEFORMAT] – time in format (for example Time:HH:MM:SS)
  • INT – integer number
  • Decimal:[DECIMALFORMAT] – Decimal number
  • Email – email address
  • Etc.

The code:

(function($) { 
    $.fn.somePlugin = function(options) { 
        var defaults = { 
            someOption: 'someValue'
        }; 
        var opts = $.extend(defaults, options); 
    };   
})(jQuery);
2
  • 1st: What exactly is your question and 2nd: you might get in trouble generating valid HTML/XHTML/XML with a non standards compliant tag. Commented Aug 24, 2010 at 17:44
  • 1. How can I realize jquery plugin using code above? Commented Aug 24, 2010 at 18:54

1 Answer 1

1

I think you could use the jQuery plugin validity as it is flexible enough for almost anything, because you can give it an assert or callback as a validation rule: Assert Demo

Sign up to request clarification or add additional context in comments.

1 Comment

Great alternative, that plugin is pretty cool, and let's you do virtualy everything

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.