Check value in a form element 
Author Message
 Check value in a form element

Hi,
with this script I check the data input in the specify form element
(Input Textbox), if I add a new record. The script works without
errors, only if I use IE5.5 (with IE6 I didn't tested) and add a new
record with input I get two times the message "The record will be
added now !" and the record is added. Without input I get at first
the message "For the field Node-Name is an entry necessary !"
later on the message "The record will be added now !" and at
least a message from the Jet Database Engine who tells me an
input for primary indexfield is absolute necessary.
I think something must be wrong in the script, maybe with the
syntax.
I hope somebody has an idea can help me !
Thanks in advance

Regards
Juergen

function thisPage_onbeforeserverevent(obj,event) {
 var BrowserName = navigator.appName;
 var BrowserVersion = parseInt(navigator.appVersion);
 var Browser;

 if (BrowserName == "Netscape" && BrowserVersion == 5) {
  Browser = "NN6";
 }
 else if (BrowserName == "Netscape" && BrowserVersion == 4) {
   Browser = "NN4";
 }
 else if (BrowserName == "Microsoft Internet Explorer" &&
   BrowserVersion == 4 &&
   navigator.appVersion.indexOf("MSIE 6.0") != -1) {
   Browser = "IE6";
 }
 else if (BrowserName == "Microsoft Internet Explorer" &&
   BrowserVersion == 4 &&
   navigator.appVersion.indexOf("MSIE 5.5") != -1) {
   Browser = "IE55";
 }
 else if (BrowserName == "Microsoft Internet Explorer" &&
   BrowserVersion == 4 &&
   navigator.appVersion.indexOf("MSIE 5.0") != -1) {
   Browser = "IE5";
 }

 if(obj=="btnDelete"){
  if(event=="onclick"){
   if(confirm("You will delete the record ?")){
    thisPage.cancelEvent = false; // OK
    }
    else {
    thisPage.cancelEvent = true; // Cancel
    }
   }
  }
 if(obj=="btnUpdate"){
  if(event=="onclick"){
   if(confirm("You will update the record ?")){
    thisPage.cancelEvent = false;
    }
    else {
    thisPage.cancelEvent = true;
    location.reload(true)
    }
   }
  }
 if(obj=="btnSave"){
  if(event=="onclick"){

   if (Browser == "IE5" || Browser == "IE55"){
    if (document.thisForm.elements[6].value == "") //It is the index
field from the database
    alert("For the field Node-Name is an entry necessary !");
    thisPage.cancelEvent = true;
    }
    if (document.thisForm.elements[6].value != ""){
    alert("The record will be added now !");
    thisPage.cancelEvent = false;
    location.href
    }
   else if
   (Browser == "NN6" || Browser == "IE6") {
    if (document.thisForm.elements[2].value == "") //It is the index
field from the database
    alert("For the field Node-Name is an entry necessary !")
    thisPage.cancelEvent = true;
    }
    if (document.thisForm.elements[2].value != ""){
    alert("The record will be added now !");
    thisPage.cancelEvent = false;
    location.href
    }
    }
 }



Wed, 08 Sep 2004 00:56:17 GMT  
 Check value in a form element
I found the answer of this problem by myself.
Juergen

Jrgen Schulz schrieb:

Quote:
> Hi,
> with this script I check the data input in the specify form element
> (Input Textbox), if I add a new record. The script works without
> errors, only if I use IE5.5 (with IE6 I didn't tested) and add a new
> record with input I get two times the message "The record will be
> added now !" and the record is added. Without input I get at first
> the message "For the field Node-Name is an entry necessary !"
> later on the message "The record will be added now !" and at
> least a message from the Jet Database Engine who tells me an
> input for primary indexfield is absolute necessary.
> I think something must be wrong in the script, maybe with the
> syntax.
> I hope somebody has an idea can help me !
> Thanks in advance

> Regards
> Juergen

> function thisPage_onbeforeserverevent(obj,event) {
>  var BrowserName = navigator.appName;
>  var BrowserVersion = parseInt(navigator.appVersion);
>  var Browser;

>  if (BrowserName == "Netscape" && BrowserVersion == 5) {
>   Browser = "NN6";
>  }
>  else if (BrowserName == "Netscape" && BrowserVersion == 4) {
>    Browser = "NN4";
>  }
>  else if (BrowserName == "Microsoft Internet Explorer" &&
>    BrowserVersion == 4 &&
>    navigator.appVersion.indexOf("MSIE 6.0") != -1) {
>    Browser = "IE6";
>  }
>  else if (BrowserName == "Microsoft Internet Explorer" &&
>    BrowserVersion == 4 &&
>    navigator.appVersion.indexOf("MSIE 5.5") != -1) {
>    Browser = "IE55";
>  }
>  else if (BrowserName == "Microsoft Internet Explorer" &&
>    BrowserVersion == 4 &&
>    navigator.appVersion.indexOf("MSIE 5.0") != -1) {
>    Browser = "IE5";
>  }

>  if(obj=="btnDelete"){
>   if(event=="onclick"){
>    if(confirm("You will delete the record ?")){
>     thisPage.cancelEvent = false; // OK
>     }
>     else {
>     thisPage.cancelEvent = true; // Cancel
>     }
>    }
>   }
>  if(obj=="btnUpdate"){
>   if(event=="onclick"){
>    if(confirm("You will update the record ?")){
>     thisPage.cancelEvent = false;
>     }
>     else {
>     thisPage.cancelEvent = true;
>     location.reload(true)
>     }
>    }
>   }
>  if(obj=="btnSave"){
>   if(event=="onclick"){

>    if (Browser == "IE5" || Browser == "IE55"){
>     if (document.thisForm.elements[6].value == "") //It is the index
> field from the database
>     alert("For the field Node-Name is an entry necessary !");
>     thisPage.cancelEvent = true;
>     }
>     if (document.thisForm.elements[6].value != ""){
>     alert("The record will be added now !");
>     thisPage.cancelEvent = false;
>     location.href
>     }
>    else if
>    (Browser == "NN6" || Browser == "IE6") {
>     if (document.thisForm.elements[2].value == "") //It is the index
> field from the database
>     alert("For the field Node-Name is an entry necessary !")
>     thisPage.cancelEvent = true;
>     }
>     if (document.thisForm.elements[2].value != ""){
>     alert("The record will be added now !");
>     thisPage.cancelEvent = false;
>     location.href
>     }
>     }
>  }



Sat, 11 Sep 2004 11:11:32 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. check for non existent form element Request.Form

2. Check for content in form-elements before submitting

3. Checking if form element exists

4. Check if form element is disabled

5. print checked elements of form ONLY

6. Iterating a form of 25000 records to set elements the checked

7. Changing the value of a form element?

8. Capturing Form element values

9. Form value to Form value * advanced question

10. Finding # of specific element in forms elements collection

11. Check Box being checked if database value is equal to ON

12. Equivalent of document.form.elements[x] on page w/o form

 

 
Powered by phpBB® Forum Software