Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function questions

Status
Not open for further replies.

TruthInSatire

Programmer
Aug 12, 2002
2,964
US
first question is I have a function that I call during onBlur and it works fine. the function puts up and alert window if an initial format is not correct. When I call the function from another function, I get three boxes, not one. I only call the function once.

second question is, if I do a return false in one function to end the function, How do I end the function that called it?


function initalcheck(fld){
ini = fld.value;
var validchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
if (validchars.indexOf(ini.toUpperCase()) < 0)
fld.select(),
alert(fld.name + ' must be one letter between A-Z or a-z');
else
fld.value = ini.toUpperCase();
}


<script language = &quot;javascript&quot; type = &quot;text/JavaScript&quot;>
function checkBeforeSave(openform){
initalcheck(document.editemp.initial);
phoneformat(document.editemp.homephone);
phoneformat(document.editemp.workphone);
phoneformat(document.editemp.pochomephone1);
phoneformat(document.editemp.pochomephone2);
phoneformat(document.editemp.pochomephone3);
phoneformat(document.editemp.pocworkphone1);
phoneformat(document.editemp.pocworkphone2);
phoneformat(document.editemp.pocworkphone3);
phoneformat(document.editemp.poccellphone1);
phoneformat(document.editemp.poccellphone2);
phoneformat(document.editemp.poccellphone3);
validdate(document.editemp.birthdate);
validdate(document.editemp.startposition);
validdate(document.editemp.depothiredate);

}
</script> How many software developers does it take to change a light bulb?
None: it works in everyone else’s office, it must work in yours too.
 
actually I get 3 boxes for every function, not just the initial one. How many software developers does it take to change a light bulb?
None: it works in everyone else’s office, it must work in yours too.
 
one problem is you don't have braces around your if statement here:

if (validchars.indexOf(ini.toUpperCase()) < 0)
fld.select(),
alert

resulting in the alert whether or not the condition is true. this should help:

if (validchars.indexOf(ini.toUpperCase()) < 0) {
fld.select(),
alert
} =========================================================
if (!succeed) try();
-jeff
 
hey jemminger, shouldn't it be:

while( !succeed ) try();

I don't want you to give up on the first try...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top