Thinkphp after the auto-validation is defined in model, after using the $this->display (template), everything that was entered on the previous page is gone, what is the method in thinkphp to keep the previously entered and focus on the wrong input box.
Reply to discussion (solution)
I'll give you a clue.
If you use Ajax, that is, when $create () Form validation fails, use the GetError () method to get the error message, return the arguments passed in the previous validation with the error message back to the past, and Ajax sets the callback function to process the information.
If it is not Ajax, you can consider using the session value in the template as an error message, there is no time to write an empty string, the validation fails to write the error message to the corresponding session, the return template will be displayed, after the successful verification of the session to clear.
What do you plan to get together if you have multiple errors?
I'll give you a clue.
If you use Ajax, that is, when $create () Form validation fails, use the GetError () method to get the error message, return the arguments passed in the previous validation with the error message back to the past, and Ajax sets the callback function to process the information.
If it is not Ajax, you can consider using the session value in the template as an error message, there is no time to write an empty string, the validation fails when the error message is written to the corresponding session, the return template will be displayed, after the success of the validation to clear the corresponding Sessio ...
The background color of all the error boxes is shown in red, focusing from top to bottom, from left to right for the first one:
Reference 1 Floor Anew_g's reply: give you a thought
If you use Ajax, that is, when $create () Form validation fails, use the GetError () method to get the error message, return the arguments passed in the previous validation with the error message back to the past, and Ajax sets the callback function to process the information.
If not Ajax, you can consider using the session value in the template as an error message, no time to write an empty string, the validation fails to write error information to the corresponding Sessi ...
These with JS control Yes
Thinkphp after the auto-validation is defined in model, after using the $this->display (template), everything that was entered on the previous page is gone, what is the method in thinkphp to keep the previously entered and focus on the wrong input box.
thinkphp
The template page is submitted to action,action using JQuery's Ajax method, which returns different values depending on the error, and the last page outputs different error prompts based on the different return values, and navigates to the specified input box.
If you need a detailed solution, please reply to me directly.
Quoted landlord Shaozengwei reply: thinkphp after the model has defined the automatic validation, after using the $this->display (template), the previous page input of everything is gone, What is the method in thinkphp to let the previously entered things still, and focus on the wrong input box.
thinkphp
Template page with jquery ... Just wrong, sorry ...
Also want to ask you a question, is thinkphp Ajax upload problem, on the Baidu is said, add an iframe on the page and then add a few input box, but I took the online said after the addition, no response. The uploaded file can be received in the background. or continue to use Ajaxreturn to return the JSON data. Can you post the source code ...
If you need a detailed solution, please reply to me directly. Please post the source code.
You can use JS to implement, commit the trigger event.
Reference 5 Floor nowphp reply: If you need a detailed solution, please reply to me directly. Please post the source code.
$.post ("{: U (' Index/index/check ')}", {Name:name}, function (Result) {if (result = =-1) {alert (' input name does not exist '); return false;} else if (result = =-2) {alert (' Input name not valid '); return false;}});
index/indexaction.class.php
function Check () { $name =$_post[' name ']; $map [' name ']= $name; $result =m (' user ')->where ($map)->find (); if ($result) { echo-1;exit; } if (!isable ($name)) { echo-2;exit; }}
$ (' #id_input '). focus ();
The first alert above should say that there is already a
Reference 7 Floor Shaozengwei's reply:
Reference 5 Floor nowphp reply: If you need a detailed solution, please reply to me directly. Please post the source code.
JavaScript Code
?
1234567891011
$.post ("{: U (' Index/index/check ')}", {Name:name}, function (Result) {... Focusing on this problem, I don't know which control is wrong, so I don't know which control to focus on and I'm going to submit a form. Need to upload video.
Can put out your code, let's look at
Can put out your code, let's look at
Public Function Uploadvideo () {//dump ($_post); $info = $this->upload (' temp ');} Public function upload ($module = ", $path =", $thumb = ", $width =", $height = ") {$module = $module =" "? ' Temp ': $module; Switch ($module) {case ' temp ': $path = C (Attachdir). '/temp/'. $path; break; Case ' storehouse ': $path = C (Attachdir). '/storehouse/'. $path; break; Case ' shop ': $path = C (Attachdir). '/shop/'. $path; break; Case ' trader ': $path = C (Attachdir). '/trader/'. $path; break; Case ' group ': $path = C (Attachdir). '/group/'. $path; break; Case ' my ': $path = C (Attachdir). '/avatar/'. $path; break; Default: $path = C (Attachdir). '/file/'. $path; } if (!is_dir ($path)) @mkdir ($path); Import ("ORG.Net.UploadFile"); $upload = new UploadFile (); $upload->maxsize = C (attachsize); $upload->allowexts = Explode (', ', Strtolower (C (Attachext))); $upload->savepath = $path; $upload->saverule = ' uniqid '; $upload->allowtypes=array (' jpg '); Empty ($thumb)? $upload->thumb = C (ATTACH): $upload->thumb = $thumb; Empty ($width)? $upload->thumbmaxwidth = C (thumbmaxwidth): $upload->thumbmaxwidth = $width; Empty ($height)? $upload->thumbmaxheight = C (thumbmaxheight): $upload->thumbmaxheight = $height; if (! $upload->upload ()) {if ($this->isajax ()) {$this->ajaxreturn (Array ("errormsg" = $upload Geterrormsg ()), ' Uploaderror ', 2; }else{return $this->error ($upload->geterrormsg ()); }}else{if ($this->isajax ()) {$this->ajaxreturn (' info ' = ' info '), ' info ', 1); }else{return $upload->getuploadfileinfo (); } } }
The problem has been resolved. Just do a static method. Knot Stickers