0

我有一个表格,我想更改 css 中错误消息的字体大小和颜色,但我不知道该怎么做。

$(document).ready(function() {
   $("#form1").validate({ 
      rules: {  
         credit: {
         required:true,
         creditcard: true
      },
      amount: { 
         required: true,
         min:(15),
      },
      firstname: "required",// simple rule, converted to {required:true} 
      surname: "required",// simple rule, converted to {required:true}   
      name2: "required",// simple rule, converted to {required:true}    
      surname2: "required",// simple rule, converted to {required:true}     
      name3: "required",// simple rule, converted to {required:true}  
   },

这些是消息,我不希望它们与表单输入的大小和颜色相同,需要弄清楚如何更改它们

      messages: {
         firstname: "Please enter a first name",
         surname: "Please enter a surname",
         name2: "Please enter a first name",
         surname2: "Please enter a surname",
         name3: "Please enter a name",
      }      
   });
});
4

1 回答 1

3

默认情况下,使用 jQuery 验证插件,当您尝试发布有错误的表单时,它会将类名添加error到所有未通过验证的表单元素。所以:

<input type="text" name="firstname"/>

会变成:

<input type="text" name="firstname" class="error"/>

要更改样式,请使用以下内容:

.error {
   color: red;
   font-size: 12px;
}
于 2013-01-20T18:42:23.620 回答