D
divya
Hiii,
Please read the following piece of code:-
function SendToWebServer1(sendto) //sendto string contains a URL
{
if (document.form1.txtbookedby.value == "")
{
alert('your name field cannot be empty');
}
else if (document.form1.txtContact.value == "")
{
alert('The extension number field cannot be empty');
}
/* else if (document.form1.txtContact.value != "") //To chk user has
added only digits
{
for (var i = 0; i <
document.form1.txtContact.value.length;i++){
var ch=document.form1.txtContact.value.charAt(i);
alert (i);
if((ch < "0" || ch > "9")){
alert('the extension field can only have numbers');
}
}
alert("successfully come out of loop");
}*/
else
{
alert("hey youve filled alll the fields correct ");
document.form1.action=sendto;
document.form1.submit();
}
}
Now the problem is with the part of code I have commented .
Problem:-
When I remove the coments ,it properly checks the first three
conditions and gives respective alert boxes when the conditions are
true.But when all the 3 conditions are false (that is conditions given
in the if ,1st elseif and 2nd elseif ) it doesnot go inside the Else
block.
Now when I add coments to the 2nd else if block ,it works fine .When
the if and the first elseif are false,it goes into the else block
displays the alert box and also performs these actions.
document.form1.action=sendto;
document.form1.submit();
as needed and takes me to the URL given in "sendto".
But when I remove the coments and all the fields are properly filled
it doesnot direct me to the string"sendto" page.
Please let me know where is the problem in the code.
Regards
Divya
Please read the following piece of code:-
function SendToWebServer1(sendto) //sendto string contains a URL
{
if (document.form1.txtbookedby.value == "")
{
alert('your name field cannot be empty');
}
else if (document.form1.txtContact.value == "")
{
alert('The extension number field cannot be empty');
}
/* else if (document.form1.txtContact.value != "") //To chk user has
added only digits
{
for (var i = 0; i <
document.form1.txtContact.value.length;i++){
var ch=document.form1.txtContact.value.charAt(i);
alert (i);
if((ch < "0" || ch > "9")){
alert('the extension field can only have numbers');
}
}
alert("successfully come out of loop");
}*/
else
{
alert("hey youve filled alll the fields correct ");
document.form1.action=sendto;
document.form1.submit();
}
}
Now the problem is with the part of code I have commented .
Problem:-
When I remove the coments ,it properly checks the first three
conditions and gives respective alert boxes when the conditions are
true.But when all the 3 conditions are false (that is conditions given
in the if ,1st elseif and 2nd elseif ) it doesnot go inside the Else
block.
Now when I add coments to the 2nd else if block ,it works fine .When
the if and the first elseif are false,it goes into the else block
displays the alert box and also performs these actions.
document.form1.action=sendto;
document.form1.submit();
as needed and takes me to the URL given in "sendto".
But when I remove the coments and all the fields are properly filled
it doesnot direct me to the string"sendto" page.
Please let me know where is the problem in the code.
Regards
Divya