jQuery Watermarked input and validation

后端 未结 5 1530
小鲜肉
小鲜肉 2020-12-19 12:38

On a HTML page I have an inputbox that has a \'watermark\' on it when it is empty. (eg: \"enter text here...\"). Kind of like this: http://digitalbush.com/projects/watermark

5条回答
  •  伪装坚强ぢ
    2020-12-19 12:53

    Thanks to Kazar for providing me with the link, I came up with the following solution (if anyone is interested):

        function notWatermark(value, element){
            return value != 'enter text...';
        }
    
        $.validator.addMethod("notWatermark", notWatermark, "Field cannot be empty.");
    
        $('#SearchForm').validate({
            rules: {
                SomeField: {
                    required: true,
                    notWatermark: true
                }
             },
    

提交回复
热议问题