E
effendi
I wrote a very simple validation fucntion to check if all fields are
entered properly in a dialog box before returning this the values to
the parent form. The validation works finr however, I am not sure if I
am doing this correctly. For example if the telephone number field is
empty, the alert box appear telling the users to enter the telephone
number. However, once I click OK. the script appear to run and I get an
error message in the "dialog box window". What I would like to do is
let the user click ok and return back to the problem field. Below is my
code.
var thisdoc=document.forms[0]
var Role=getSelectedText(thisdoc.Role)
var MemberLookup=thisdoc.MemberLookup.value
if(Role==">>>Select Role") {
alert("Please select a role for this Team member")
thisdoc.Role.focus();
return
}
if (Role.substring(0,2)=="01" && thisdoc.TeamLeadAppt.value=="Y"){
alert("You can appoint only one person as Team Leader")
}
var ContactNo=thisdoc.ContactNumber.value
if(ContactNo.value==" ") {
alert("Please enter a Contact Number Team member")
thisdoc.ContactNumber.focus();
return;
}
if(ContactNo.length!=8) {
alert("Please enter a valid 8 digit telephone number this Team
member")
thisdoc.Role.focus();
return;
}
if(ContactNo.length!=8) {
alert("Please enter a valid 8 digit telephone number this Team
member")
thisdoc.Role.focus();
return;
}
window.opener.teamSelectionCallback(MemberLookup,Role,ContactNo)
window.close()
entered properly in a dialog box before returning this the values to
the parent form. The validation works finr however, I am not sure if I
am doing this correctly. For example if the telephone number field is
empty, the alert box appear telling the users to enter the telephone
number. However, once I click OK. the script appear to run and I get an
error message in the "dialog box window". What I would like to do is
let the user click ok and return back to the problem field. Below is my
code.
var thisdoc=document.forms[0]
var Role=getSelectedText(thisdoc.Role)
var MemberLookup=thisdoc.MemberLookup.value
if(Role==">>>Select Role") {
alert("Please select a role for this Team member")
thisdoc.Role.focus();
return
}
if (Role.substring(0,2)=="01" && thisdoc.TeamLeadAppt.value=="Y"){
alert("You can appoint only one person as Team Leader")
}
var ContactNo=thisdoc.ContactNumber.value
if(ContactNo.value==" ") {
alert("Please enter a Contact Number Team member")
thisdoc.ContactNumber.focus();
return;
}
if(ContactNo.length!=8) {
alert("Please enter a valid 8 digit telephone number this Team
member")
thisdoc.Role.focus();
return;
}
if(ContactNo.length!=8) {
alert("Please enter a valid 8 digit telephone number this Team
member")
thisdoc.Role.focus();
return;
}
window.opener.teamSelectionCallback(MemberLookup,Role,ContactNo)
window.close()