我有一个表单和ajax call.data被填充到表单中,并且同时用户在我的数据库中使用ajax调用来创建远程。但问题出在验证,其中验证应该在这里适用 例如我应用任何jquery验证我需要测试如果表单是有效的,然后我可以调用ajax如果表单有效其他明智的数据库将填充空白数据 我试着用bvalidator但我不知道如何检测的形式是有效的,或者使用任何的jQuery验证库无效只有在jQuery验证有效的情况下才会调用Ajax
<form id="inform" action="http://site.com">
<input type="text" id="name" />
<input type="text" id="email" />
<input type="button" name="subaction" id="infuse" />
</form>
<script language ="javascript" type = "text/javascript" >
$na= jQuery.noConflict();
$na(document).ready(function(){
$na('#infuse').click(function(){
var name= $na('#name').val();
var email = $na('#email').val();
$na.ajax({
type: "POST",
url: '<?php bloginfo('template_url')?>/user_create.php',
data: 'name='+name+'&email='+email,
cache: false,
success: function(result){
jQuery('.err_msg').html(result);
jQuery("#inform").submit();
}
});
});
});
</script>
您的问题似乎存在拼写错误。你真的想将'email'中的值存储在一个名为'age'的变量中,而不再使用它? –
难道你不可能写你自己的验证,更适合你的应用程序吗? –
你错了我写它它不是原来的版本,但我需要的是有效的形式前ajax调用,如果有效去ajax过程 – Vishal