Get the App
SLTechnology News&Howtos  ›  Development  › 

How to validate mailboxes asynchronously by thinkphp5

Shulou Source: shulou.com Published: 2022-06-03 14:16:50 09月17日 Update

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!

Tags: Authentication mailbox user name content article between background address password namely attribute format length learning help input legal consistent successful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno MariaDB Linux Microsoft