function isNull(field , fieldName) {
      fieldIsNull = 0;
      if ( field.type == "text" || field.type == "password" || field.type == "hidden" ||
           field.type == "file" || field.type == "textarea" ) {
         if (( field.value == "" ) || (field.value.replace(/^s*|s*$/g,"") =="" ))
           fieldIsNull = 1;
      }
      if ( fieldIsNull ) {
        if ( typeof fieldName == "undefined" )
          alert( "Значение не может быть пустым.");
        else
          alert("Значение поля " + fieldName + " не может быть пустым" );
        if ( field.type == "text" || field.type == "textarea"  || field.type == "password" )
          field.focus();
        field.select();
        return false;
      }
      return true;
}

function isNUM(field , fieldName) {
      fieldIsNull = 0;
      fieldContent = field.value.split(".");
      if ( field.type == "text" || field.type == "password" || field.type == "hidden" ||
           field.type == "textarea" ) {
        if ( (field.value == "") || (field.value.replace(/^s*|s*$/g,"") =="" ) || (isNaN(field.value)) || (field.value<=0)
             || ( (field.value.indexOf(".")!=-1) && (field.value.indexOf(".")<field.value.length-3) )
             || ( (field.value.indexOf(".")==-1) && (field.value.length>13))
             || (field.value.indexOf(",")!=-1)
             || ( (field.value.indexOf(".")!=-1) && (field.value.indexOf(".")>13))
             || ((fieldContent.length != 1) && (fieldContent.length != 2) )
           )
          fieldIsNull = 1;
      }
      if ( fieldIsNull ) {
        if (typeof fieldName == "undefined")
          alert( "Значение поля должно принимать положительные значения в формате 99999999(9).99" );
        else
          alert("Значение поля " + fieldName + " должно принимать положительные значения в формате 999999999999999999.99");
        if ( field.type == "text" || field.type == "textarea"  || field.type == "password" )
          field.focus();

        field.select();
        return false;
      }

      return true;
}

function TestForm(){
      if (!isNull(document.forms["payment"].elements["paySumm"], "Сумма к оплате")) {
        return false;
      } if (!isNUM(document.forms["payment"].elements["paySumm"], "Сумма к оплате")) {
        return false;
      }
      return true;
}
