Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to validate mailboxes asynchronously by thinkphp5

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "thinkphp5 how to asynchronously verify mailboxes", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "thinkphp5 how to asynchronously verify mailboxes" this article.

TP5 uses bootstrapvalidator to asynchronously verify mailboxes

Js verification / * Created by HONGXIN on 2017-10-23. * / $(function () {$('form') .bootstrapValidator ({message:' This value is not valid', feedbackIcons: {valid: 'glyphicon glyphicon-ok', invalid:' glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh'}, live:' disabled',// after verification fails The submit button is still optional fields: {email: {message: 'username verification failed', / / default verbose: false, validators: {notEmpty: {message: 'mailbox cannot be empty'} EmailAddress: {message: 'incorrect email address format'}, remote: {url:'/ ajax_email', message: "this mailbox is already registered", type: "post" DataType: 'json', data: {/ / what is passed by default is the value of the input box}, delay: 500 penalty / delay effect},}} Password: {validators: {notEmpty: {message: 'email address cannot be empty'}, stringLength: {min: 6, max: 18 Message: 'user name must be between 6 and 18 digits'} Password2: {validators: {notEmpty: {message: 'confirm that the password cannot be empty'}, identical: {field: 'password' Message: 'password must be the same twice'}, username: {validators: {notEmpty: {message: 'user name cannot be empty'} StringLength: {min: 2, max: 8, message: 'username length must be between 2 and 8 digits'}}) }); TP5 processes public function ajax_email () {/ / the message can be empty, which replaces the message attribute echo json_encode of JS verification (['valid'= > false,'message'= >' incorrect verification code']);} js verifies several points for attention

Verbose: false, which means that js authentication is legal and then asynchronous background verification is performed to reduce server pressure.

Data: {}, the value of the input box is passed by default, so you don't have to write this property, or you can leave it empty.

Pay attention to the background.

Notice it's not return, it's echo.

Returns the json format {'valid':true [,' message':' successful']}

The above is all the contents of the article "how to verify mailboxes asynchronously by thinkphp5". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 240

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report