Location: PHPKode > projects > Library Accounting System > library/movie_module/m_validate.php
<?php if($url_blocker != "75726C00"){Header("Location: ./"); exit;}?> 
<script type="text/javascript">

function testResults (form) {
var cango = 0

        if (form.title.value != "" && form.release.value != ""){

    form.director.value = formatnames(form.director.value);
    form.actors.value = formatnames(form.actors.value);
    form.writer.value = formatnames(form.writer.value);

// create the call number

var part1 = form.medium.value;
var stringLen = form.title.value.length;

  for (var i = 0; i < stringLen; i++)
  var tmparray = form.title.value.split(" ");
  var tmpstring =""
          if (tmparray.length > 1){
      tmpstring += tmparray[0] +"_"+ tmparray[1];
          }else{
          tmpstring += tmparray[0]
          }
   
  var part3 = tmpstring;



    var part4 = form.release.value

// if there is no call number set it sets it.
// if there is one it checks if there is a suffix and uses it if there is.
if (form.callnum.value.match(/\(/g) == null){
form.callnum.value = part1 + ":" + part3 + "|" + part4
}else{
res = form.callnum.value.split(":")
form.callnum.value = part1 + ":" + part3 + "|" + part4 + ":" + res[2]
}
}


if (form.title.value == ""){
document.getElementById("title").style.color = "red";
cango += 1
}else{
document.getElementById("title").style.color = "black";
}
if (form.release.value == ""){
    document.getElementById("release").style.color = "red";
cango += 1
}else{
    document.getElementById("release").style.color = "black";
}


if (cango == 0) {
  document.form1.submit()
}

}




function trimString (str) {
return RTrim(LTrim(str));
}

function LTrim(str)
{
var whitespace = new String(" \t\n\r ");
var s = new String(str);
if (whitespace.indexOf(s.charAt(0)) != -1) {
var j=0, i = s.length;
while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
j++;
s = s.substring(j, i);
}
return s;
}

function RTrim(str)
{
var whitespace = new String(" \t\n\r ");
var s = new String(str);
if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
var i = s.length - 1;
while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
i--;
s = s.substring(0, i+1);
}
return s;
}

function formatnames(str){
    var Formata = str
            if (Formata.match(",") == null){
        if (Formata.match("&") == null){
        

            var res = Formata.split(" ")
                    x = res.length
                    var i = 0
                    if (x > 1){
                str = res[x-1] + ", "
                for (i=0;i<x-1;i++){
                    str += res[i] + " "
                }
                    }else{
                        str = res[x-1]
                    }
                    str = trimString(str)
        }else{
                        res = Formata.split("&")
                                x = res.length
                                i = 0
                                str = ""
                                for (i=0;i<x;i++)
                        {
                            res2 = trimString(res[i]).split(" ")
                                    y = res2.length
                                    K = 0
                                    str += res2[y-1] + ", "
                                    for (K=0;K<y-1;K++){
                                str += res2[K] + " "
                                    }
                                    if(i < x-1){
                                        str += "& "
                                    }
                        }

                 }

            }

            return str;

}

function image(){
    var  ddcpopup = window.open('./edit_image.php?doing=<?=$res['refurl']?>','popupWindow','width=600,height=300');
}
</script>
 
Return current item: Library Accounting System