0

I am using Semantic UI along with ASP.NET MVC. I have performed client-side validation in my registration form as described in the documentation http://semantic-ui.com/modules/form.html Now i want to validate an email in order to be unique. So i have to make an ajax request to the server (this is something i know how to do). But how can i add such a rule in Semantic UI and display a corresponding error message?

4

1 回答 1

0

在文档中进行了一些搜索后,我发现了这种行为add errors。它像

$('.your.ui.form').form('add errors', ['Your error string 1', 'Maybe another one?']);

但是,这只会更改错误消息中的文本。如果当时没有显示错误消息,您可能想要显示它。将类“错误”添加到表单中:

$('.your.ui.form').addClass('error');

当然,您可以链接这两种方法,例如

$('.ui.form')
  .form('add errors', ['oh my error'])
  .addClass('error');

这是一个小提琴

于 2014-10-04T19:30:56.997 回答