Home > Backend Development > PHP Tutorial > 登记页面对应的函数得不到文本控件的值

登记页面对应的函数得不到文本控件的值

WBOY
Release: 2016-06-13 12:07:06
Original
922 people have browsed it

注册页面对应的函数得不到文本控件的值
注册页面对应的函数:

<br />$.post('{:U("Register/register")}', $('#register'), function(str) {     //  .serialize()<br />
Copy after login


RegisterAction.class.php 中:
<br />//注册<br />    public function register() { <br />        $data['u_username'] = strtolower(I('name', '', 'trim'));<br />        $data['u_phone'] = I('phone', '', 'trim');<br />        $data['u_email'] = I('email', '', 'trim');<br />        $data['u_password'] = I('pass');<br />        $data['repassword'] = I('rpass');<br />        $rpass = I('rpass');<br />        ... ...<br />
Copy after login

这几个变量得到的值都是空的,为什么呢?

在register模板文件中,
<br />if (email === 0 || phone === 0 || code === 0 || username === 0 || password === 0 || rpassword === 0) {<br />...<br />
Copy after login

这几个email等变量的值都是0

<br />if (document.getElementById("email").value === 0 || document.getElementById("phone").value === 0 || document.getElementById("code").value === 0 || document.getElementById("username").value === 0 || document.getElementById("password").value === 0 || document.getElementById("rpassword").value === 0) {<br />
Copy after login

改成这样就都取到各个文本框控件的值了。

文本框代码:
<br /><input  name="email" id="email" maxlength="30" /><br />
Copy after login

------解决思路----------------------
如果 register 是表单的id
那么
$.post('{:U("Register/register")}', $('#register') .serialize(), function(str) { .......   

------解决思路----------------------
关注,友情帮顶!
------解决思路----------------------
print_r(json_decode(' {"info":"\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef!","status":0,"url":""}'));

stdClass Object
(
    [info] => 验证码输入错误!
    [status] => 0
    [url] => 
)

你没按规矩来!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template