使用PHP失败的jQuery Mobile表单验证 [英] jQuery Mobile Form Validation with PHP Failing

查看:151
本文介绍了使用PHP失败的jQuery Mobile表单验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHP后端构建的jQuery Mobile网站中的某些表单字段中添加一些验证.

I'm trying to add some validation to some form fields in a jQuery Mobile site I'm building with a PHP back end.

我过去已经成功使用jquery.validate插件完成了此操作,但是我很难使它与jQuery Mobile一起使用.

I've done this in the past successfully using the jquery.validate plugin but I'm having trouble getting this to work with jQuery Mobile.

此jsFiddle页面中的验证工作:

The validation is working in this jsFiddle page:

http://jsfiddle.net/GeX5C/5/

但是,当我从托管的PHP页面中单击提交"按钮时,无法启动它.从我读到的内容来看,我不能使用通常的方式:

but I'm having trouble getting it to fire when I click the submit button from the hosted PHP page. From what I've read I can't use the usual:

$(document).ready(function(){

方法,但不确定用什么替代?

approach but not sure what to replace this with?

非常感谢您的任何帮助.

Would really appreciate any assistance here.

谢谢

推荐答案

仅供参考,这是适用于表单验证的js代码:

FYI this is js code that works for the form validation:

$('#id-for-the-page-element').live( 'pageinit',function(event){ 
  $('#id-for-the-form').validate(options);
});

希望这对其他人有帮助.

Hope this helps someone else.

这篇关于使用PHP失败的jQuery Mobile表单验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆