【发布时间】:2015-11-15 03:32:56
【问题描述】:
我正在尝试检查var a=document.forms["reg"]["matricula"].value; 是否存在于我的数据库中,但用户将使用此值!
如何检查我的数据库中是否存在 var "a"?
function validateForm()
{
var a=document.forms["reg"]["matricula"].value;
var b=document.forms["reg"]["nome"].value;
var c=document.forms["reg"]["cargo"].value;
if ((a==null || a=="") && (b==null || b=="") && (c==null || c==""))
{
alert("Todos os campos devem ser preenchidos!");
return false;
}
if (a==null || a=="")
{
alert("A matrícula deve ser preenchida!");
return false;
}
if (b==null || b=="")
{
alert("O nome deve ser preenchido!");
return false;
}
if (c==null || c=="")
{
alert("O cargo deve ser selecionado!");
return false;
}
}
【问题讨论】:
-
带有选择查询?
-
创建一个单独的 php 文件,将您的 php 代码放在那里,然后通过 ajax 从您的 js 中提取该页面值。
-
@Dagon,是的!查询
-
嗯,写一个?你在问我们什么?
标签: javascript php html mysql sql