使用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:
但是,当我从托管的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.