[困惑] - Javascript导致页面重新加载 [英] [baffled] - Javascript causes page to reload

查看:93
本文介绍了[困惑] - Javascript导致页面重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一套在线保险表格。这些已经从凌乱的MS Word模板中删除了,并且六个中的两个,即基本相同的
,在.js页面上行为不端,验证了

部分内容。


正确的行为是某些字段必须包含内容,有些字段必须

具有有效日期/时间。在验证时,表单被发布到处理页面,该页面将其转换为空白模板并将电子邮件发送到其他地方。


出错的两个检测到空/错字段,弹出警报窗口

up,但不是正确的行为,将页面焦点移动到

空字段并等待,页面重新加载,看似是GET

命令 - 地址窗口将URL显示为:
http://xxxx.xxx.xx/zsf/PLhouse.asp?t ... e = PL& intform = 6

& Claimno =& IncidentDepartmentCd =& IncidentDepartment =& CustomerRef =& Incident

Date =& IncidentTime =& COBAddress0 =& COBAddress1 = & COBA ddress2 =& COBAddress3

=& COBAddress4

=& COBPostCode =& PLNatureOfLossCode =& PLNatureOfLoss =& PLCauseCode =& PLCause =& ;

PLOccupationCode = & PLOccupation =& PLEmpStatusCode =& P LEmpStatus =& AccidentOcc

urred =& ContractorsInvolved =& ContractorsNatureInv =& ContractorsInsurers =& Cl

aimNo2

=& ClaimantRef =& ClaimantTitle =& ClaimantInitials =& Cl aimantName =& ClaimantAge

=& ClaimantNINo =& ClaimantAddress0 =& ClaimantAddress1 =& ClaimantAddress2

=& ClaimantAddress3 =& ClaimantAddress4

=& ClaimantPostCode =& ClaimantOccupation = & HospitalDe tails =& ClaimantInsurers

=& ClaimOralOrWritten =& ClaimantDateCeasedWork =& Clai mantDateResumedWork =& Cl

aimantDateLeftWork =& SolicitorDetails =& SolicitorAdd ress0

=& SolicitorAddress1 =& SolicitorAddress2 =& SolicitorA ddress3

=& SolicitorAddress4

=& SolicitorPostCode =& SolicitorRef =& ClaimantInjuryC ode =& ClaimantInjury =& Cl

aimantDamageCode =& ClaimantDamage =& COBTypeOfPremise sCd =& COBTypeOfPremises =

& COBLocationCode =& COBLocation =& ClaimNo3

=& Inspec tionLastDate =& InspectionBy =& InspectionCond ition =& ComplaintsPrior =

& ComplaintsMadeBy =& ComplaintsMadeTo =& ComplaintsAct ion =& RecordOfComplaints

=& ComplaintRecorded =& PropClaimSeen =& PropClaimConfi rm =& Witness1Name =& Witne

ss1Address1 =& ClaimNo4

=& CustomerCodeHOU =& CustomerCodeBLD =& CustomerCodeCL G =& CustomerCodeCMS =& Cus

tomerCodeEVS =& CustomerCodeCPS =& CustomerCodeGDM =& Cu stomerCodeHHS =& Customer

CodePGD =& CustomerCodePPY = & CustomerCodeCTG =& Custome rCodeGML =& CustomerCodeM

AG =& CustomerCodePKO =& CustomerCodePCT =& CustomerCode BUC =& CustomerCodeRLS =& C

ustomerCodeSIS =安培; CustomerCodeETN =安培; CustomerCodeRSE =安培; CustomerCodeVEH =& Custom

erCodeWTD =& CustomerCodeFDT =& CustomerCodePOL =& Custo merCodeITS =& CustomerCod

eERD =& CustomerCodeSPH =& CustomerCodeAIR =& ; CustomerCo deOTH =& ClaimNo5

=& Signature =& SignedDate =& Designation =& AdditionalIn fo =

这让我感到困惑。为什么会这样做? .js页面是

以下


'''''''''''''''''''' '$'$

function form_confirm(Formname){


var probflag = false;

// IncidentDate - 必须具有有效格式并填写

var dt = document.forms [Formname] .IncidentDate.value;

dt = dt.replace(/ ^ [\ s] + / g,''''); //前导空格 - > null

dt = dt.replace(/ [\ s] + $ / g,''''); //尾随空格 - > null

if(dt ==""){

alert(事件日期必须填写);

文件.forms [Formname] .IncidentDate.focus();

probflag = true;

返回false;

}

udt = dt;

if(udt.indexOf(" /&))== -1){

alert(''不是有效日期,格式''+ dtFormat);

document.forms [Formname] .IncidentDate.focus();

返回false;

}

dt1 = udt.split(" /")

dd1 = parseInt(dt1 [0]);

mm1 = parseInt(dt1 [1 ]);

yy1 = parseInt(dt1 [2]);

// if(isNaN(dd1)|| isNaN(mm1)|| isNaN(yy1)) {

if(isNaN(dd1)|| isNaN(yy1)){

alert(''事件日期无效日期!'');

document.forms [Formname] .IncidentDate.focus();

返回false;

}

// IncidentTime

var dt = document.forms [Formname] .IncidentTime.value;

dt = dt.replace(/ ^ [\ s] + / g, ); //前导空格 - > null

dt = dt.replace(/ [\ s] + $ / g,''''); //尾随空格 - > null

if(dt ==""){

alert(事件时间必须填写);

文件.forms [Formname] .IncidentTime.focus();

probflag = true;

返回false;

}

udt = dt;

dtFormat =" HH:MM";

if(udt.indexOf(":")== -1){

alert(''不是有效时间 - 必须格式为''+ dtFormat);

document.forms [Formname] .IncidentTime.focus();

返回false;

}

dt1 = udt.split(":")

hh1 = parseInt(dt1 [0]);

mm1 = parseInt(dt1 [1]);

// yy1 = parseInt(dt1 [2]);

// if(isNaN(dd1)|| isNaN(mm1)|| isNaN(yy1)){

if(isNaN(hh1)|| isNaN(mm1)){

alert(''事件发生时间无效!'');

document.forms [Formname] .IncidentTime.focus();

返回false; < br $>
}


// COBAddress1 - 发生损失的地址街道必须为f



var dt = document.forms [Formname] .COBAddress1.value;

dt = dt.replace(/ ^ [\\ \\s] + /克, '' ''); //前导空格 - > null

dt = dt.replace(/ [\ s] + $ / g,''''); //尾随空格 - > null

if(dt ==""){

alert(地址必须填写);

文件。表格[Formname] .COBAddress1.focus();

probflag = true;

返回false;

}

// ClaimantName - 不是''属性''表格

if(Formname!=''PR'')

{


var dt = document.forms [Formname] .ClaimantName.value;

dt = dt.replace(/ ^ [\ s] + / g,''''); //前导空格 - > null

dt = dt.replace(/ [\ s] + $ / g,''''); //尾随空格 - > null

if(dt ==""){

alert(索赔人名称必须填写);

文件.forms [Formname] .ClaimantName.focus();

probflag = true;

返回false;

}

}

// IncidentDepartment - 相关部门必须填写

// var dt = document.forms [Formname] .IncidentDepartment.value;

// dt = dt.replace(/ ^ [\ s] + / g,''''); //前导空格 - > null

// dt = dt.replace(/ [\ s] + $ / g,''''); //尾随空格 - > null

// alert("复选框1 [" + document.forms

[Formname] .CheckHOU.checked +"]");

if(document.forms [Formname] .CheckHOU.checked == false&&

document.forms [Formname] .CheckBLD.checked == false&&& br />
document.forms [Formname] .CheckCLG.checked == false&&

document.forms [Formname] .CheckCMS.checked == false

&&

document.forms [Formname] .CheckEVS.checked == false&&

document.forms [Formname] .CheckCPS.checked == false

&& document.forms [Formname] .CheckGDM.checked == false&&

document.forms [Formname] .CheckHHS.checked == false

&& document.forms [Formname] .CheckPGD.checked == false&&

document.forms [Formname] .CheckPPY.checked == false

&& document.forms [Formname] .CheckCTG.checked == false&&

document.forms [Formname] .CheckGML.checked == f另外

&& document.forms [Formname] .CheckMAG.checked == false&&

document.forms [Formname] .CheckPKO.checked == false

&& document.forms [Formname] .CheckPCT.checked == false&&

document.forms [Formname] .CheckBUC.checked == false

&& document.forms [Formname] .CheckRLS.checked == false&&

document.forms [Formname] .CheckSIS.checked == false

&& document.forms [Formname] .CheckETN.checked == false&&

document.forms [Formname] .CheckRSE.checked == false

&& document.forms [Formname] .CheckVEH.checked == false&&

document.forms [Formname] .CheckWTD.checked == false

&& document.forms [Formname] .CheckFDT.checked == false&&

document.forms [Formname] .CheckPOL.checked == false

&& document.forms [Formname] .CheckITS.checked == false&&

document.forms [Formname] .CheckERD.checked == false

&& document.forms [Formname] .CheckSPH.checked == false&&

document.forms [Formname] .CheckAIR.checked == false

&& document.forms [Formname] .CheckOTH.checked == false)

{

alert(部门必须填写);

document.forms [Formname] .CheckHOU.focus();

probflag = true;

返回false;

}

// if(Formname!=''MO'')

// {

// if(document.forms [Formname] .CheckFTD.checked == false)

// {

// alert(部门必须填写);

//document.forms [Formname] .CheckHOU.focus();

// probflag = true;

//返回false;

//}

//}

//签名 - 签名必须填写

var dt = document.forms [Formname] .Signature.value;

dt = dt.replace(/ ^ [\ s] + / g,''''); //前导空格 - > null

dt = dt.replace(/ [\ s] + $ / g,''''); //尾随空格 - > null

if(dt ==""){

alert(签名必须填写);

文件。表格[Formname] .Signature.focus();

probflag = true;

返回false;

}

//指定 - 必须填写指定

var dt = document.forms [Formname] .Designation.value;

dt = dt.replace( / ^ [\s] + /克, '' ''); //前导空格 - > null

dt = dt.replace(/ [\ s] + $ / g,''''); //尾随空格 - > null

if(dt ==""){

alert(指定必须填写);

文件。表格[Formname] .Designation.focus();

probflag = true;

返回false;

}

// SignedDate - 必须具有有效格式并填写

var dt = document.forms [Formname] .SignedDate.value;

dt = dt .replace(/ ^ [\s] + /克, '' ''); //前导空格 - > null

dt = dt.replace(/ [\ s] + $ / g,''''); //尾随空格 - > null

if(dt ==""){

alert(应输入完成日期);

文件。 form [Formname] .SignedDate.focus();

probflag = true;

返回false;

}

udt = dt;

if(udt.indexOf(" /&))== -1){

alert(''不是有效日期,格式' '+ dtFormat);

document.forms [Formname] .SignedDate.focus();

返回false;

}

dt1 = udt.split(" /")

dd1 = parseInt(dt1 [0]);

mm1 = parseInt(dt1 [1] );

yy1 = parseInt(dt1 [2]);

// if(isNaN(dd1)|| isNaN(mm1)|| isNaN(yy1)){

if(isNaN(dd1)|| isNaN(yy1)){

alert(''签名日期无效日期!'');

document.forms [Formname] .SignedDate.focus();

返回false;

}

// if(probflag = false &&(确认(''你确定要提交

这个表格?'')))

if(confi rm(''你确定要提交这份表格吗?'')){

if(probflag == false)

{

NewWindow('''',''zurich_form_qfp'',''650'','''400'',''是'');

document.forms [Formname] .method = " POST"

document.forms [Formname] .action =" zurich_forms.asp"

document.forms [Formname] .target =" zurich_form_qfp"

document.forms [Formname] .submit();

}

}

}

'''''''''''''''''''''''''''''' '''这些

I''m building a suite of online forms for insurance. These have been
stripped down from messy MS Word templates, and two of the six,
substantially identical, are misbehaving with the .js page that validates
some of the content.

The correct behaviour is that some fields must have content, some must
have valid dates/times. On validation, the form is POSTed to a processing
page that flows it into a blank template and emails that elsewhere.

The two that go wrong detect the empty/wrong fields, pop the alert window
up, but instead of the correct behaviour, to move the page focus to the
empty field and wait, the page is reloaded, with what appears to be a GET
command - the address window displays the URL as:
http://xxxx.xxx.xx/zsf/PLhouse.asp?t...e=PL&intform=6
&Claimno=&IncidentDepartmentCd=&IncidentDepartment =&CustomerRef=&Incident
Date=&IncidentTime=&COBAddress0=&COBAddress1=&COBA ddress2=&COBAddress3
=&COBAddress4
=&COBPostCode=&PLNatureOfLossCode=&PLNatureOfLoss= &PLCauseCode=&PLCause=&
PLOccupationCode=&PLOccupation=&PLEmpStatusCode=&P LEmpStatus=&AccidentOcc
urred=&ContractorsInvolved=&ContractorsNatureInv=& ContractorsInsurers=&Cl
aimNo2
=&ClaimantRef=&ClaimantTitle=&ClaimantInitials=&Cl aimantName=&ClaimantAge
=&ClaimantNINo=&ClaimantAddress0=&ClaimantAddress1 =&ClaimantAddress2
=&ClaimantAddress3=&ClaimantAddress4
=&ClaimantPostCode=&ClaimantOccupation=&HospitalDe tails=&ClaimantInsurers
=&ClaimOralOrWritten=&ClaimantDateCeasedWork=&Clai mantDateResumedWork=&Cl
aimantDateLeftWork=&SolicitorDetails=&SolicitorAdd ress0
=&SolicitorAddress1=&SolicitorAddress2=&SolicitorA ddress3
=&SolicitorAddress4
=&SolicitorPostCode=&SolicitorRef=&ClaimantInjuryC ode=&ClaimantInjury=&Cl
aimantDamageCode=&ClaimantDamage=&COBTypeOfPremise sCd=&COBTypeOfPremises=
&COBLocationCode=&COBLocation=&ClaimNo3
=&InspectionLastDate=&InspectionBy=&InspectionCond ition=&ComplaintsPrior=
&ComplaintsMadeBy=&ComplaintsMadeTo=&ComplaintsAct ion=&RecordOfComplaints
=&ComplaintRecorded=&PropClaimSeen=&PropClaimConfi rm=&Witness1Name=&Witne
ss1Address1=&ClaimNo4
=&CustomerCodeHOU=&CustomerCodeBLD=&CustomerCodeCL G=&CustomerCodeCMS=&Cus
tomerCodeEVS=&CustomerCodeCPS=&CustomerCodeGDM=&Cu stomerCodeHHS=&Customer
CodePGD=&CustomerCodePPY=&CustomerCodeCTG=&Custome rCodeGML=&CustomerCodeM
AG=&CustomerCodePKO=&CustomerCodePCT=&CustomerCode BUC=&CustomerCodeRLS=&C
ustomerCodeSIS=&CustomerCodeETN=&CustomerCodeRSE=& CustomerCodeVEH=&Custom
erCodeWTD=&CustomerCodeFDT=&CustomerCodePOL=&Custo merCodeITS=&CustomerCod
eERD=&CustomerCodeSPH=&CustomerCodeAIR=&CustomerCo deOTH=&ClaimNo5
=&Signature=&SignedDate=&Designation=&AdditionalIn fo=
This is what''s got me baffled. Why would it do that? The .js page is
below

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''

function form_confirm (Formname){

var probflag = false;
// IncidentDate - must have valid format and be filled in
var dt = document.forms[Formname].IncidentDate.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+$/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Incident Date must be filled in");
document.forms[Formname].IncidentDate.focus();
probflag=true;
return false;
}
udt = dt;
if(udt.indexOf("/") == -1){
alert(''Not a valid date, format ''+dtFormat);
document.forms[Formname].IncidentDate.focus();
return false;
}
dt1 = udt.split("/")
dd1 = parseInt(dt1[0]);
mm1 = parseInt(dt1[1]);
yy1 = parseInt(dt1[2]);
//if(isNaN(dd1) || isNaN(mm1) || isNaN(yy1)){
if(isNaN(dd1) || isNaN(yy1)){
alert(''Invalid Date for Incident Date !'');
document.forms[Formname].IncidentDate.focus();
return false;
}
// IncidentTime
var dt = document.forms[Formname].IncidentTime.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+$/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Incident Time must be filled in");
document.forms[Formname].IncidentTime.focus();
probflag=true;
return false;
}
udt = dt;
dtFormat = "HH:MM";
if(udt.indexOf(":") == -1){
alert(''Not a valid time - must be in format ''+dtFormat);
document.forms[Formname].IncidentTime.focus();
return false;
}
dt1 = udt.split(":")
hh1 = parseInt(dt1[0]);
mm1 = parseInt(dt1[1]);
//yy1 = parseInt(dt1[2]);
//if(isNaN(dd1) || isNaN(mm1) || isNaN(yy1)){
if(isNaN(hh1) || isNaN(mm1)){
alert(''Invalid Time for Incident Time !'');
document.forms[Formname].IncidentTime.focus();
return false;
}

// COBAddress1 - street of address where loss occured must be filled
in
var dt = document.forms[Formname].COBAddress1.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+$/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Address must be filled in");
document.forms[Formname].COBAddress1.focus();
probflag=true;
return false;
}
// ClaimantName - not for ''property'' form
if (Formname != ''PR'')
{

var dt = document.forms[Formname].ClaimantName.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+$/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Claimant Name must be filled in");
document.forms[Formname].ClaimantName.focus();
probflag=true;
return false;
}
}
// IncidentDepartment - department concerned must be filled in
//var dt = document.forms[Formname].IncidentDepartment.value;
//dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
//dt = dt.replace(/[\s]+$/g,''''); // trailing whitespace -> null
//alert ("check box 1 [" +document.forms
[Formname].CheckHOU.checked+ "]" );
if (document.forms[Formname].CheckHOU.checked == false &&
document.forms[Formname].CheckBLD.checked == false &&
document.forms[Formname].CheckCLG.checked == false &&
document.forms[Formname].CheckCMS.checked == false
&&
document.forms[Formname].CheckEVS.checked == false &&
document.forms[Formname].CheckCPS.checked == false
&& document.forms[Formname].CheckGDM.checked == false &&
document.forms[Formname].CheckHHS.checked == false
&& document.forms[Formname].CheckPGD.checked == false &&
document.forms[Formname].CheckPPY.checked == false
&& document.forms[Formname].CheckCTG.checked == false &&
document.forms[Formname].CheckGML.checked == false
&& document.forms[Formname].CheckMAG.checked == false &&
document.forms[Formname].CheckPKO.checked == false
&& document.forms[Formname].CheckPCT.checked == false &&
document.forms[Formname].CheckBUC.checked == false
&& document.forms[Formname].CheckRLS.checked == false &&
document.forms[Formname].CheckSIS.checked == false
&& document.forms[Formname].CheckETN.checked == false &&
document.forms[Formname].CheckRSE.checked == false
&& document.forms[Formname].CheckVEH.checked == false &&
document.forms[Formname].CheckWTD.checked == false
&& document.forms[Formname].CheckFDT.checked == false &&
document.forms[Formname].CheckPOL.checked == false
&& document.forms[Formname].CheckITS.checked == false &&
document.forms[Formname].CheckERD.checked == false
&& document.forms[Formname].CheckSPH.checked == false &&
document.forms[Formname].CheckAIR.checked == false
&& document.forms[Formname].CheckOTH.checked == false)
{
alert("Department must be filled in");
document.forms[Formname].CheckHOU.focus();
probflag=true;
return false;
}
//if (Formname != ''MO'')
//{
// if (document.forms[Formname].CheckFTD.checked == false)
// {
// alert("Department must be filled in");
//document.forms[Formname].CheckHOU.focus();
//probflag=true;
//return false;
// }
//}
// Signature - Signature must be filled in
var dt = document.forms[Formname].Signature.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+$/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Signature must be filled in");
document.forms[Formname].Signature.focus();
probflag=true;
return false;
}

// Designation - Designation must be filled in
var dt = document.forms[Formname].Designation.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+$/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Designation must be filled in");
document.forms[Formname].Designation.focus();
probflag=true;
return false;
}

// SignedDate - must have valid format and be filled in
var dt = document.forms[Formname].SignedDate.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+$/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Completed Date should be entered");
document.forms[Formname].SignedDate.focus();
probflag=true;
return false;
}
udt = dt;
if(udt.indexOf("/") == -1){
alert(''Not a valid date, format ''+dtFormat);
document.forms[Formname].SignedDate.focus();
return false;
}
dt1 = udt.split("/")
dd1 = parseInt(dt1[0]);
mm1 = parseInt(dt1[1]);
yy1 = parseInt(dt1[2]);
//if(isNaN(dd1) || isNaN(mm1) || isNaN(yy1)){
if(isNaN(dd1) || isNaN(yy1)){
alert(''Invalid Date for Signed Date !'');
document.forms[Formname].SignedDate.focus();
return false;
}
//if (probflag = false && (confirm(''Are you sure you want to submit
this form?'')))
if (confirm(''Are you sure you want to submit this form?'')){
if (probflag==false)
{
NewWindow('''',''zurich_form_qfp'',''650'',''400'',''yes'');
document.forms[Formname].method="POST"
document.forms[Formname].action="zurich_forms.asp"
document.forms[Formname].target="zurich_form_qfp"
document.forms[Formname].submit();
}
}
}
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

推荐答案

/ g,''''); //尾随空格 - > null

if(dt ==""){

alert(事件日期必须填写);

文件.forms [Formname] .IncidentDate.focus();

probflag = true;

返回false;

}

udt = dt;

if(udt.indexOf(" /&))== -1){

alert(''不是有效日期,格式''+ dtFormat);

document.forms [Formname] .IncidentDate.focus();

返回false;

}

dt1 = udt.split(" /")

dd1 = parseInt(dt1 [0]);

mm1 = parseInt(dt1 [1 ]);

yy1 = parseInt(dt1 [2]);

// if(isNaN(dd1)|| isNaN(mm1)|| isNaN(yy1)) {

if(isNaN(dd1)|| isNaN(yy1)){

alert(''事件日期无效日期!'');

document.forms [Formname] .IncidentDate.focus();

返回false;

}

// IncidentTime

var dt = document.forms [Formname] .IncidentTime.value;

dt = dt.replace(/ ^ [\ s] + / g, ); //前导空格 - > null

dt = dt.replace(/ [\ s] +
/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Incident Date must be filled in");
document.forms[Formname].IncidentDate.focus();
probflag=true;
return false;
}
udt = dt;
if(udt.indexOf("/") == -1){
alert(''Not a valid date, format ''+dtFormat);
document.forms[Formname].IncidentDate.focus();
return false;
}
dt1 = udt.split("/")
dd1 = parseInt(dt1[0]);
mm1 = parseInt(dt1[1]);
yy1 = parseInt(dt1[2]);
//if(isNaN(dd1) || isNaN(mm1) || isNaN(yy1)){
if(isNaN(dd1) || isNaN(yy1)){
alert(''Invalid Date for Incident Date !'');
document.forms[Formname].IncidentDate.focus();
return false;
}
// IncidentTime
var dt = document.forms[Formname].IncidentTime.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+


/ g,''''); //尾随空格 - > null

if(dt ==""){

alert(事件时间必须填写);

文件.forms [Formname] .IncidentTime.focus();

probflag = true;

返回false;

}

udt = dt;

dtFormat =" HH:MM";

if(udt.indexOf(":")== -1){

alert(''不是有效时间 - 必须格式为''+ dtFormat);

document.forms [Formname] .IncidentTime.focus();

返回false;

}

dt1 = udt.split(":")

hh1 = parseInt(dt1 [0]);

mm1 = parseInt(dt1 [1]);

// yy1 = parseInt(dt1 [2]);

// if(isNaN(dd1)|| isNaN(mm1)|| isNaN(yy1)){

if(isNaN(hh1)|| isNaN(mm1)){

alert(''事件发生时间无效!'');

document.forms [Formname] .IncidentTime.focus();

返回false; < br $>
}


// COBAddress1 - 发生损失的地址街道必须为f



var dt = document.forms [Formname] .COBAddress1.value;

dt = dt.replace(/ ^ [\\ \\s] + /克, '' ''); //前导空格 - > null

dt = dt.replace(/ [\ s] +
/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Incident Time must be filled in");
document.forms[Formname].IncidentTime.focus();
probflag=true;
return false;
}
udt = dt;
dtFormat = "HH:MM";
if(udt.indexOf(":") == -1){
alert(''Not a valid time - must be in format ''+dtFormat);
document.forms[Formname].IncidentTime.focus();
return false;
}
dt1 = udt.split(":")
hh1 = parseInt(dt1[0]);
mm1 = parseInt(dt1[1]);
//yy1 = parseInt(dt1[2]);
//if(isNaN(dd1) || isNaN(mm1) || isNaN(yy1)){
if(isNaN(hh1) || isNaN(mm1)){
alert(''Invalid Time for Incident Time !'');
document.forms[Formname].IncidentTime.focus();
return false;
}

// COBAddress1 - street of address where loss occured must be filled
in
var dt = document.forms[Formname].COBAddress1.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+


/ g,''''); //尾随空格 - > null

if(dt ==""){

alert(地址必须填写);

文件。表格[Formname] .COBAddress1.focus();

probflag = true;

返回false;

}

// ClaimantName - 不是''属性''表格

if(Formname!=''PR'')

{


var dt = document.forms [Formname] .ClaimantName.value;

dt = dt.replace(/ ^ [\ s] + / g,''''); //前导空格 - > null

dt = dt.replace(/ [\\\] + +
/g,''''); // trailing whitespace -> null
if (dt == "") {
alert("Address must be filled in");
document.forms[Formname].COBAddress1.focus();
probflag=true;
return false;
}
// ClaimantName - not for ''property'' form
if (Formname != ''PR'')
{

var dt = document.forms[Formname].ClaimantName.value;
dt = dt.replace(/^[\s]+/g,''''); // leading whitespace -> null
dt = dt.replace(/[\s]+


这篇关于[困惑] - Javascript导致页面重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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