[转载]easyui表单数据验证

[转载]easyui表单数据验证.

   <form id="ff" method="post">
        <div>
            <label for="name">
                Name:</label>
            <input class="easyui-validatebox" type="text" name="name" required="true" validtype="length[5,12]"></input>
        </div>
        <div>
            <label for="email">
                Email:</label>
            <input class="easyui-validatebox" type="text" name="email" required="true" validtype="email" invalidMessage="邮箱格式错误"></input>
        </div>
        <div>
            <label for="subject">
                Subject:</label>
            <input class="easyui-validatebox" type="text" name="subject" required="true" missingMessage="不能为空"></input>
        </div>
        <div>
            <label for="message">
                Message:</label>
            <textarea name="message" style="height: 60px;"></textarea>
        </div>
        <div>
            <input type="submit" value="Submit">
        </div>
        </form>

Validate Rule

The validate rule is defined by using required and validType property, here are the rules already implemented:

  • email: Match email regex rule.
  • url: Match URL regex rule.
  • length[0,100]: Between x and x characters allowed.
  • remote[‘http://…/action.do’,’paramName’]: Send ajax request to do validate value, return ‘true’ when successfully.

Properties

Name Type Description Default
required boolean Defines if the field should be inputed. false
validType string Defines the field valid type, such as email, url, etc. null
missingMessage string Tooltip text that appears when the text box is empty. This field is required.
invalidMessage string Tooltip text that appears when the content of text box is invalid. null

http://www.jeasyui.com/documentation/validatebox.php

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏