Adding errors to form validation doesn't work?

后端 未结 4 1831
予麋鹿
予麋鹿 2021-01-21 11:47

According to the Semantic UI docs on form validation, I can add errors manually:

add errors(errors) | Adds errors to form, given an array errors

4条回答
  •  萌比男神i
    2021-01-21 12:09

    It appears like you are trying to recreate the wheel when using semantic ui. Assuming you have included the complete versions of semantic.css in the head and semantic.js just above the body closing tag, here is an abbreviated version of working code for a simple contact form with some of the error work done by semantic and some by html5. For completeness I have included a user side captcha. HTML

    mainjs

        $(function(){
     $('form input[type=reset]')
                .before('
    Are you a human?

    '); $('.ui.form').form({ email: { identifier: 'email', rules: [ { type: 'empty', prompt: 'Please enter your email' } ] }, subject: { identifier: 'subject', rules: [ { type: 'empty', prompt: 'Please enter a subject' } ] }, message: { identifier: 'message', rules: [ { type: 'empty', prompt: 'Please enter a message' } ] }, human: { identifier: 'captcha', rules: [ { type: 'checked', prompt: 'You must behuman' } ] } }); });

    I hope this helps to clear things up.

提交回复
热议问题