以下是我的javascript code.i驗證表單數據爲我使用如果conditions.if它得到正確驗證,然後隱藏所有警告,如果不顯示只有警告的該feild並返回false.but該函數不返回false。 代碼:html表單驗證的javascript函數返回值
function check_form()
{
var name=document.signin_form.full_name.value;
var userid=document.signin_form.userid.value;
var gender=document.signin_form.gender.value;
var dob=document.signin_form.dob.value;
var add=document.signin_form.address.value;
var pass=document.signin_form.pass.value;
var tc=document.signin_form.tc.checked;
if(name!==""&&name.length<30&&name.match(/^[A-Za-z]+$/))
{
right();
}
else
{
wrong("name");
return false;
}
}
function right()
{
$(document).ready(function(){
$("#name_warning").css("display","none");
$("#userid_warning").css("display","none");
$("#gender_warning").css("display","none");
$("#dob_warning").css("display","none");
$("#address_warning").css("display","none");
$("#password_warning").css("display","none");
$("#tc_warning").css("display","none");
});
}
function wrong(str)
{
str="'#"+str+"_warning'";
$(document).ready(function(){
$(str).css("display","inline-block");
});
window.scroll(0,250);
}
你有什麼樣的輸入? –
請提供一個[mcve] –