
/* Function to check field value entered on form */
function checkvalues(form) {
        
        /* Get value entered by user and strip ld/tr spaces*/
        field=form.field.value;
        field=trim(field);
        form.field.value=field;

        /* Check that something was entered if not show error and return false
*/
        if(field=="") {
                alert("You must enter a value for this field");
                return(false);
        } else {

        /* If something entered check field for invalid characters, in this
case must */
        /* be alpha numeric N.B note the last parameter of 0 indicating check
is not */
        /* case sensitive */

                if (validvalue(field,"abcdefghijklmnopqrstuvwxyz1234567890",0)) {
                                                
                        /* All okay so submit form */
                        document.example.submit();
                        return(true);
                } else {
        
                        /* Invalid characters in field so show alert box and return false
*/              
                        alert("Podano nieprawidlowe znaki !!!");
                        return(false);
                }
        }
}
/*
========================================================================
============== */
/* Function to strip leading and trailing spaces from value (similar to
Java trim method) */
/*
========================================================================
============== */
/* Input is string to be trimmed and return value is the result after
trimming */

function trim(value) {

        /* Strip leading spaces from input */
        startposn=0;
        while((value.charAt(startposn)==" ")&&(startposn<value.length)) {
                startposn++;
        }
        if(startposn==value.length) {
                value="";
        } else {

                /* If anything left of string after stripping leading spaces strip
trailing */
                /* spaces as well */
                value=value.substring(startposn,value.length);
                endposn=(value.length)-1;
                while(value.charAt(endposn)==" ") {
                        endposn--;
                }
                value=value.substring(0,endposn+1);
        }
        return(value);
}

/* ====================================================================
*/
/* Function to check that field value doesn't contain spaces or numbers
*/
/* ====================================================================
*/
/* Inputs are the string to be checked, the characters to be allowed and
flag value indicating */
/* if check on letters is to be case sensitive, where 1 inidcates it is
case sensitive */
/* Return code is true is field value is valid, false if not. */
function validvalue(value,validchars,casesensitive) {
 
  // value=trim(value);
        //form.field.value=field;
 //alert("Podano jeszcze nieprawidlowe znaki !!!");
 
		/* If not case sensitive then convert both value and valid */
        /* characters to upper case */
        if (casesensitive!=1) {
                value=value.toUpperCase();
                validchars=validchars.toUpperCase();
        }

        /* Go through each character in value until either end or hit an
invalid char */
        charposn=0;
        while
((charposn<value.length)&&(validchars.indexOf(value.charAt(charposn))!=-
1)) {
                charposn++;
        }

        /* Check if stop was due to end of input string or invalid char and set
return code */
        /* accordingly */
        if (charposn==value.length) {
		       return(true);
        } else {
			   return(false);
        }

		
}


