星期五, 2月 22, 2013

[jQuery plugin] 浮水印+驗證器

浮水印加在inputbox是常見的功能需求,但有時候需要與驗證器整合。

function notWatermark(value, element){
        return value != 'enter text...';
    }

    $.validator.addMethod("notWatermark", notWatermark, "Field cannot be empty.");

    $('#SearchForm').validate({
        rules: {
            SomeField: {
                required: true,
                notWatermark: true
            }
         },

Reference:jQuery Watermarked input and validation

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails