Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SdlBasic 29.97 KB | None | 0 0
  1. /* Array to get viewname for correspounding form name   */
  2. /* Array to get viewname for correspounding form name   */
  3. var viewName=new Array(
  4.                                                   ["frmAssignee","vwAssigneeDetails"],
  5.                                                   ["frmKeywords","vwKeywords"],
  6.                                                   ["frmInvoiceSuffix","vwInvoiceSuffix"]
  7.                                                   )
  8. /*function UniqueCheck (fieldvalue, fieldtext ,valueList)
  9. Description : Is used to check uniqueness of thye entry
  10. */
  11. function UniqueCheck (fieldvalue, fieldtext ,valueList)
  12. {
  13.  
  14. var length,temp
  15. var i,exist
  16.  
  17. var arr=new Array();
  18.  
  19. arr = valueList.split("; ")
  20. length = arr.length
  21.  
  22.  
  23.    for(i=0;i<length;i++)
  24.      {
  25.          if(Trim(fieldvalue.toLowerCase())==Trim(arr[i].toLowerCase()))
  26.              {
  27.                 alert(fieldtext+"  Already Exists")
  28.                  return 1;
  29.             }
  30.    
  31.     }
  32. return 0;
  33. }
  34.  
  35. /*
  36.  function IsBlank (fieldvalue, fieldtext)
  37.  Description:  Is used to validate field for blank values
  38. */
  39. function IsBlank (fieldvalue, fieldtext)
  40. {
  41.   if(Trim(fieldvalue)=="" || Trim(fieldvalue)=="----Select----")
  42.     {
  43.        alert("Please Enter "+ fieldtext);
  44.      
  45.        return 1;
  46.      }
  47.   return 0;
  48. }
  49.  
  50.  
  51. /*
  52.  function IsBlankForList (fieldvalue ,fieldtext)
  53.  Description:  Is used to check for blank value for drop down fields
  54. */
  55.  
  56. function IsBlankForList (fieldvalue ,fieldtext)
  57. {
  58.   if(Trim(fieldvalue)=="" || Trim(fieldvalue)=="----- Please Select -----")
  59.     {
  60.        alert("Please Select "+ fieldtext);
  61.      
  62.        return 1;
  63.      }
  64.   return 0;
  65. }
  66. /*
  67.  function ContainsSpecialChar(str)
  68.  Description:  Is used to check whether string contains a special charecter
  69. */
  70.  
  71. function ContainsSpecialChar(fieldValue ,fieldText)
  72. {
  73.     var iChars = "`~!@#$%^*()+=\\-[]';,{}|\":<>?";
  74.   var isPresent = 0;
  75.    for (var i = 0; i < fieldValue.length; i++)
  76.       {
  77.     if (iChars.indexOf(fieldValue.charAt(i)) != -1)
  78.        {
  79.        alert (fieldText + " could not contain special charecters");
  80.        //return false;
  81.        isPresent=1;
  82.        break;
  83.        }
  84.     }
  85.     return isPresent
  86. }
  87. /*
  88. function StringLength(fieldvalue , fieldtext,length)
  89. Description:  This function is used to check the length of a string.
  90. */
  91.  
  92.  
  93. function StringLength(fieldvalue,fieldtext,length)
  94. {
  95. //alert(Trim(fieldvalue).length)
  96. if((Trim(fieldvalue).length) > length)
  97. {
  98.    alert(fieldtext + " should be less than or equal to "+ length +"  characters");
  99.     return 1;       // to indicate in the calling function that error has occurred.
  100. }
  101.     return 0;
  102.    
  103. }
  104.  
  105. /*
  106. function IsNumbFirst(fieldValue,fieldText)
  107. Description:  Is used to check whether there is a number in a string at first position
  108. */
  109.  
  110. function IsNumbFirst(fieldValue,fieldText)
  111. {
  112. //  var numaric = alphane;
  113. //  var alphaa = numaric.charAt(j);
  114.     var firstChar = fieldValue.charCodeAt(0);
  115.     if(hh > 47 && hh<58)
  116.      {
  117.          alert(fieldText + "should not contain numeric charecter at first position")
  118.         return 1;
  119.       }
  120.     else
  121.     {
  122.          return 0;
  123.      }
  124. }
  125.  
  126. /*
  127. function ContainsNumber(temp ,FieldText)
  128. Description:  This Function checks if string contains numbers
  129. */
  130.  
  131. function ContainsNumber(fieldValue ,FieldText)
  132. {
  133. if (FieldValue.search("0")!= -1||FieldValue.search("1")!= -1 || FieldValue.search("2")!= -1|| FieldValue.search("3")!= -1 ||FieldValue.search("4")!= -1|| FieldValue.search("5")!= -1|| FieldValue.search("6")!= -1|| FieldValue.search("7")!= -1|| FieldValue.search("8")!= -1|| FieldValue.search("9")!= -1 )
  134.       {
  135.         alert( "Numbers Not Allowed In " + FieldText )
  136.         return 1;
  137.       }
  138.          return 0;
  139. }
  140.  
  141. function IsNumb (fieldValue , fieldText )
  142. {
  143.         if ( isNaN(fieldValue)== true)
  144.         {
  145.         alert(fieldText +" has to be numeric")
  146.         return 1
  147.         }
  148.        
  149.       return 0;
  150. }
  151.  
  152. /*
  153. function IsNumb1 (fieldValue , fieldText )
  154. Description:  Is used to check for numeric values
  155. */
  156. function IsNumb1 (fieldValue , fieldText )
  157. {
  158.         if ( isNaN(fieldValue)== false)
  159.         {
  160.         alert(fieldText +" should not be Number")
  161.         return 1
  162.         }
  163.        
  164.       return 0;
  165. }
  166.  
  167.  
  168. /*
  169. function goback()
  170. Description:  Is used to navigate back by one page
  171. */
  172. function goback()
  173. {
  174. window.history.go(-1)
  175. }
  176.  
  177. /*
  178. function AlphaNumeric(alphane)
  179. Description:  Is used to validate Alphanumeric value
  180. */
  181.  
  182. function AlphaNumeric(alphane)
  183. {
  184.     var numeric = alphane;
  185.     for(var j=0; j<numeric.length; j++)
  186.         {
  187.           var alphaa = numeric.charAt(j);
  188.           var hh = alphaa.charCodeAt(0);
  189.           if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
  190.           {
  191.           }
  192.         else    {
  193.              return false;
  194.           }
  195.         }
  196. return true;
  197. }
  198.  
  199.  
  200.  
  201.  
  202. /*
  203. function Trim(str)
  204. Description:  Is used to trim the given value
  205. */
  206.  
  207. function Trim(str)
  208. {
  209.  if (str == null )
  210.  {
  211.   return ""
  212.  }
  213.   var first =0
  214.   while(str.charAt(first)==" ")
  215.    {
  216.       first++
  217.    }
  218.   //alert(first)
  219.    var last=str.length
  220.    //alert(last)
  221.    if(first==last)
  222.    {
  223.       return ""
  224.    }
  225.    while(str.charAt(last-1)==" ")
  226.     {
  227.       last--
  228.     }
  229.     //alert(last)
  230.    return str.substring(first,last)
  231.   //f.DepartmentName.value=f.DepartmentName.value.substring(first,last)
  232. }
  233.  
  234.  
  235. /*
  236. function ToProperCase(s)
  237. Description:  Is used to convert a string into a proper case string
  238. */
  239. function ToProperCase(s)
  240. {
  241.  return s.toLowerCase().replace(/^(.)|\s(.)/g,
  242.          function($1) { return $1.toUpperCase(); });
  243. }
  244.  
  245. /*
  246. function EmailCheck(str)
  247. Description:  Is used to check whether string is a email id
  248. */
  249.  
  250. function EmailCheck(str) {
  251.  
  252.         var at="@"
  253.         var dot="."
  254.         var lat=str.indexOf(at)
  255.         var lstr=str.length
  256.         var ldot=str.indexOf(dot)
  257.         if (str.indexOf(at)==-1){
  258.            alert("Invalid E-mail ID")
  259.            return true
  260.         }
  261.  
  262.         if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
  263.            alert("Invalid E-mail ID")
  264.            return true
  265.         }
  266.  
  267.         if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
  268.            alert("Invalid E-mail ID")
  269.             return true
  270.         }
  271.  
  272.          if (str.indexOf(at,(lat+1))!=-1){
  273.            alert("Invalid E-mail ID")
  274.             return true
  275.          }
  276.  
  277.          if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
  278.             alert("Invalid E-mail ID")
  279.             return true
  280.          }
  281.  
  282.          if (str.indexOf(dot,(lat+2))==-1){
  283.            alert("Invalid E-mail ID")
  284.             return true
  285.          }
  286.        
  287.          if (str.indexOf(" ")!=-1){
  288.             alert("Invalid E-mail ID")
  289.             return true
  290.          }
  291.  
  292.          return false
  293. }
  294.  
  295. /*
  296. function ProperCase(str)
  297. Description:  Is used to convert a string to a proper case string
  298. */
  299.  
  300.  
  301. function ProperCase(str)
  302. {
  303.  var arr,str_ret
  304.  str_ret=""
  305.  str=str.toLowerCase()
  306.  arr=str.split(" ")
  307.  for(var i=0;i<arr.length;i++)
  308.  {
  309.   if(arr[i]!="")
  310.   str_ret=str_ret+arr[i].replace(arr[i].charAt(0),arr[i].charAt(0).toUpperCase())+" "
  311.  }
  312.  return str_ret;
  313. }
  314.  
  315. /*
  316. function Lengthcheck(fieldvalue, fieldText, reqlength)
  317. Description:  This function is used to check the length of a string.
  318. */
  319.  
  320.  
  321. function Lengthcheck(fieldvalue, fieldText, reqlength)
  322. {  
  323.    
  324.   if (fieldvalue.length > reqlength)
  325.    {
  326.     alert(fieldText + " should be less than or equal to "+ reqlength +"  characters")
  327.         return 1;
  328.    }
  329.    
  330.         return 0;
  331. }
  332.  
  333.  
  334. function fonclick()
  335. {
  336.  var f=document.forms[0];
  337.   f.onClick();
  338. }
  339.  
  340. /*
  341. function DateCheck(startdate,enddate,FieldText,FieldText1)
  342. Description:  This Function checks if start date is greater than end date
  343. */
  344.  
  345. function DateCheck(startdate,enddate,FieldText,FieldText1)
  346. {
  347.     var tmp = startdate.split("/",3);
  348. //  var allocDat = new Date(tmp);
  349.       var allocDat=tmp[1]+"/"+tmp[0]+"/"+tmp[2]
  350. //alert(tmp[1])
  351. //alert(tmp[0])
  352. //alert(tmp[2])
  353.         var stdt=Date.parse(allocDat)
  354.       //  alert(stdt+"stdt")
  355.     var tmp1 = enddate.split("/",3);
  356.     var dueDat = tmp1[1]+"/"+tmp1[0]+"/"+tmp1[2];
  357. //alert(tmp1[1])
  358. //alert(tmp1[0])
  359. //alert(tmp1[2])
  360.     var eddt=Date.parse(dueDat)
  361.    
  362. //alert(eddt+"eddt")
  363.    if(eddt < stdt)
  364.     {  
  365.         alert(FieldText + " can not be greater than"+ FieldText1);
  366.         return 1;
  367.     }
  368. return 0;
  369. }
  370.  
  371. /*
  372. function StartDateCheck(startdate,FieldText)
  373. Description:  This Function checks if start date is less than equal to current date
  374. */
  375.  
  376. function StartDateCheck(startdate,FieldText)
  377. {
  378.     //alert(startdate)
  379.     var tmp = startdate.split("/",3)
  380.     var w=tmp[1]+"/"+tmp[0]+"/"+tmp[2]
  381.     var q = Date.parse(w)
  382.     var today=new Date()
  383.     var x=today.getUTCDate()
  384.      var y=today.getUTCMonth()
  385.     y=y+1
  386.     var z=today.getUTCFullYear()
  387.     var t= y+"/"+x+"/"+z
  388.     var l=Date.parse(t)
  389.     if(q < l)
  390.     {  
  391.         //alert("inside lezss")
  392.         alert(FieldText +" cannot be less than Current Date");
  393.         return 1;
  394.     }
  395.     return 0;
  396. }
  397.  
  398. /*
  399. function PrintPage()
  400. Description:  This Function is used to print a Form
  401. */
  402. function PrintPage()
  403. {
  404. window.print()
  405. }
  406.  
  407. ////////abhi
  408.  
  409. function StartDateCheckForGreat1(startdate,FieldText)
  410. {
  411.    
  412.     var tmp = startdate.split("/",3)
  413.  
  414. if(tmp[1]="Jan")
  415. {
  416. tmp[1]=1
  417. }
  418.     if(tmp[1]="Feb")
  419. {
  420. tmp[1]=2
  421. }
  422.  
  423. if(tmp[1]="Mar")
  424. {
  425. tmp[1]=3
  426. }
  427.  
  428. if(tmp[1]="Apr")
  429. {
  430. tmp[1]=4
  431. }
  432.  
  433. if(tmp[1]="May")
  434. {
  435. tmp[1]=5
  436. }
  437.  
  438. if(tmp[1]="Jun")
  439. {
  440. tmp[1]=6
  441. }
  442.  
  443. if(tmp[1]="Jul")
  444. {
  445. tmp[1]=7
  446. }
  447.  
  448. if(tmp[1]="Aug")
  449. {
  450. tmp[1]=8
  451. }
  452.  
  453. if(tmp[1]="Sep")
  454. {
  455. tmp[1]=9
  456. }
  457. if(tmp[1]="Oct")
  458. {
  459. tmp[1]=10
  460. }
  461. if(tmp[1]="Nov")
  462. {
  463. tmp[1]=11
  464. }
  465.  
  466. if(tmp[1]="Dec")
  467. {
  468. tmp[1]=12
  469. }
  470.  
  471. /////abhi
  472. var w=tmp[1]+"/ "+tmp[0]+"/ "+tmp[2]
  473.    
  474.     var q = Date.parse(w)
  475.     // q.toLocaleString()
  476.  
  477.     var today=new Date()
  478.     var x=today.getUTCDate()
  479.      var y=today.getUTCMonth()
  480.     y=y+1
  481.     var z=today.getUTCFullYear()
  482.     var t= y+" /"+x+"/ "+z
  483.     var l=Date.parse(t)
  484.   //  l.toLocaleString()
  485.     if(q > l)
  486.     {  
  487.         alert(FieldText +" cannot be greater than Current Date");
  488.         return 1;
  489.     }
  490.     return 0;
  491. }
  492.  
  493.  
  494. /////abhi ends
  495. /*
  496. function DisableField(webForm,fieldDet)
  497. Description:  This Function is used to disable all fields on a Form
  498. */
  499.  
  500. function DisableField(webForm,disFieldDet)
  501. {
  502.     for(var i=0;i<disFieldDet.length;i++)
  503.     {
  504.         if(disFieldDet[i][0]==1)
  505.         {
  506.             eval("webForm."+disFieldDet[i][1]+".readOnly=true")
  507.         }
  508.         else if(disFieldDet[i][0]==2)
  509.         {
  510.             eval("webForm."+disFieldDet[i][1]+".disabled=true")
  511.         }
  512.         else if(disFieldDet[i][0]==3)
  513.         {
  514.             for(var j=0;j<disFieldDet[i][2];j++)
  515.             {
  516.                 eval("webForm."+disFieldDet[i][1]+"["+j+"].disabled=true")
  517.                 //alert("webForm."+disFieldDet[i][1])
  518.                 //alert(j)
  519.             }  
  520.         }
  521.     }
  522. }
  523.  
  524. /*
  525. function EnableField(webForm,fieldDet)
  526. Description:  This Function is used to enable all fields on a Form
  527. */
  528.  
  529. function EnableField(webForm,disFieldDet)
  530. {
  531.     for(var i=0;i<disFieldDet.length;i++)
  532.     {
  533.         if(disFieldDet[i][0]==1)
  534.         {
  535.             eval("webForm."+disFieldDet[i][1]+".readOnly=false")
  536.         }
  537.         else if(disFieldDet[i][0]==2)
  538.         {
  539.             eval("webForm."+disFieldDet[i][1]+".disabled=false")
  540.         }
  541.         else if(disFieldDet[i][0]==3)
  542.         {
  543.             for(var j=0;j<disFieldDet[i][2];j++)
  544.             {
  545.                 eval("webForm."+disFieldDet[i][1]+"["+j+"].disabled=false")
  546.             }  
  547.         }
  548.     }
  549.  
  550. }
  551.  
  552.  
  553. function ShowSaveButton()
  554. {
  555. var saveNClose = document.getElementById("saveNClose");
  556. var editDocument = document.getElementById("editDocument");
  557.  
  558. saveNClose.style.display=''
  559. editDocument.style.display='none'
  560. }
  561.  
  562.  
  563. function dateDifference(fieldvalue,fieldvalue)
  564. {
  565. var f = document.forms(0)
  566. var date1=new Date(f.date_1.value)
  567. var date2 = new Date(f.date_2.value)
  568. var one_day=1000*60*60*24
  569. f.noofdate.value=(Math.ceil((date1.getTime()-date2.getTime())/(one_day))+1+
  570. " Days difference");
  571. return true
  572. }
  573.  
  574. function checkfilename()
  575. {
  576. var form=document.forms(0)
  577. var allfields=form.elements.length
  578. alert(allfields)
  579. var fieldtype
  580. var fieldvalue
  581. for(i=0;i<allfields;i++)
  582. {
  583.  fieldtype=form.elements[i].type
  584.  //alert(fieldtype)
  585.  fieldvalue=form.elements[i].value
  586.  //alert(fieldvalue)
  587.      if(fieldtype=="file")
  588.       break
  589.  }
  590. // check for blank file path
  591.  if(fieldvalue=="")
  592.  {
  593.  alert("Please select file")
  594.  return false
  595.  }
  596.  else
  597.  {
  598.   // check for bad characters in file path
  599.   var start=fieldvalue.lastIndexOf("\\")+1
  600.   end=fieldvalue.length
  601.   var filename=fieldvalue.slice(start,end)
  602.  var badchars=" !"+'"'+"£$%^&*()+'/\?,@`|¬"
  603. var check  
  604. for(c=0;c<badchars.length;c++)
  605.   {
  606.    check=filename.indexOf(badchars.substring(c,c+1))
  607.     if(check != -1)
  608.     {
  609.       alert("Not a valid file name."+check)
  610.       return false
  611.      }
  612.      
  613.     }  
  614.  
  615.   }
  616.   return true
  617. }
  618.  
  619. /*
  620. Function SetFieldValues(webForm,fieldName)
  621. Description : Sets the lookup value in individual fields in the given order
  622.  */
  623. function SetFieldValues(webForm,fieldNames,lkpFieldName)
  624. {
  625.     var lkpFieldValue=new Array()
  626.     lkpFieldValue=webForm[lkpFieldName].value.split("!#")
  627.    
  628.     for(var i=0;i<fieldNames.length;i++)
  629.     {
  630.         webForm[fieldNames[i]].value=lkpFieldValue[i]
  631.      }
  632. }
  633.  
  634. /*
  635. function Validate(webForm,fieldDet)
  636. fieldDet: fieldName,fieldPrompt,Option,extras
  637. Option :
  638. IsBlank
  639. IsNumbFirst
  640. IsNumb
  641. IsNotNumb
  642. ContainsNumber
  643. IsBlankForList
  644. LengthCheck : strlen
  645. EmailCheck  
  646. StringLength   : strlen
  647. StartDateCheckGreat
  648. DateCheck  : enddate field name
  649. StartDateCheckLess
  650. CheckFileName
  651. AlphaNumeric
  652. ContainsSpecialChar
  653. UniqueCheck  : lookup field name
  654. */
  655.  
  656. //function Validate(webForm,FieldDet)
  657. function Validate(webForm,fieldDet)
  658. {
  659.    
  660.     for(var i=0;i<fieldDet.length;i++)
  661.     {
  662.         //  alert(alert(fieldDet[i][0])+"   -  "+fieldDet[i][2]);
  663. switch(fieldDet[i][2])
  664.         {
  665.             /*
  666.             IsBlank (fieldvalue, fieldtext)
  667.              Description:  Is used to validate field for blank values
  668.             */
  669.         case "IsBlank":
  670.                  if(Trim(webForm[fieldDet[i][0]].value)=="" || Trim(webForm[fieldDet[i][0]].value)=="----Select----")
  671.                     {
  672.                       alert("Please Enter "+ fieldDet[i][1]);
  673.                      
  674.                         webForm[fieldDet[i][0]].focus();
  675.                       return 1;
  676.                      }
  677.                          
  678.                     break
  679.                 /*
  680.             IsBlankForSelection (fieldvalue, fieldtext)
  681.              Description:  Is used to validate field for blank values
  682.             */
  683.         case "IsBlankForSelection":
  684.                
  685.                    if(Trim(webForm[fieldDet[i][0]].value)=="" || Trim(webForm[fieldDet[i][0]].value)=="----Select----")
  686.                     {
  687.                       alert("Please Select "+ fieldDet[i][1]);
  688.                       webForm[fieldDet[i][0]].focus();
  689.                       return 1;
  690.                      }
  691.                          
  692.                     break  
  693.                 /*
  694.             IsBlankForSection (fieldvalue, fieldtext)
  695.              Description:  Is used to validate field for blank values (those field under hidden section)
  696.             */
  697.         case "IsBlankForSection":
  698.                
  699.                    if(Trim(webForm[fieldDet[i][0]].value)=="" || Trim(webForm[fieldDet[i][0]].value)=="----Select----")
  700.                     {
  701.                       alert("Please Enter "+ fieldDet[i][1]);
  702.                      
  703.                         //webForm[fieldDet[i][0]].focus();
  704.                       return 1;
  705.                      }
  706.                          
  707.                     break  
  708.             /*
  709.             IsNumbFirst(fieldValue,fieldText)
  710.             Description:  Is used to check whether there is a number in a string at first position
  711.             */
  712.         case "IsNumbFirst":
  713.                
  714.                 var firstChar = webForm[fieldDet[i][0]].value.charCodeAt(0);
  715.                
  716.                 if(firstChar > 47 && firstChar<58)
  717.                 {
  718.                     alert(fieldDet[i][1] + " should not contain numeric character at first position")
  719.                 webForm[fieldDet[i][0]].value="";                  
  720.                 webForm[fieldDet[i][0]].focus();
  721.                     return 1;
  722.                 }
  723.                
  724.                 break
  725.    
  726.             /*
  727.             function IsNumb (fieldValue , fieldText )
  728.             Description:  Is used to check for numeric values
  729.             */ 
  730.         case "IsNumb":
  731.    
  732.                     if ( isNaN(webForm[fieldDet[i][0]].value)== true)
  733.                     {
  734.                     alert(fieldDet[i][1] +" should be Number")
  735.                     webForm[fieldDet[i][0]].value="";
  736.                     webForm[fieldDet[i][0]].focus();
  737.                     return 1
  738.                     }
  739.            
  740.                 break
  741.             /*
  742.             function IsNotNumb (fieldValue , fieldText )
  743.             Description:  Is used to check for numeric values
  744.             */ 
  745.         case "IsNotNumb":
  746.    
  747.                     if ( isNaN(webForm[fieldDet[i][0]].value)== false)
  748.                     {
  749.                     alert(fieldDet[i][1] +" should not be Number")
  750.                     webForm[fieldDet[i][0]].value="";
  751.                     webForm[fieldDet[i][0]].focus();
  752.                     return 1
  753.                     }
  754.            
  755.                     break
  756.                    
  757.             /*
  758.             function ContainsNumber(temp ,FieldText)
  759.             Description:  This Function checks if string contains numbers
  760.             */
  761.         case "ContainsNumber":
  762.                
  763.                     if (webForm[fieldDet[i][0]].value.search("0")!= -1||webForm[fieldDet[i][0]].value.search("1")!= -1 || webForm[fieldDet[i][0]].value.search("2")!= -1|| webForm[fieldDet[i][0]].value.search("3")!= -1 || webForm[fieldDet[i][0]].value.search("4")!= -1|| webForm[fieldDet[i][0]].value.search("5")!= -1|| webForm[fieldDet[i][0]].value.search("6")!= -1|| webForm[fieldDet[i][0]].value.search("7")!= -1|| webForm[fieldDet[i][0]].value.search("8")!= -1|| webForm[fieldDet[i][0]].value.search("9")!= -1 )
  764.                       {
  765.                         alert( "Numbers Not Allowed In " + fieldDet[i][1])
  766.                         webForm[fieldDet[i][0]].value="";
  767.                         webForm[fieldDet[i][0]].focus();
  768.                         return 1;
  769.                         }  
  770.                
  771.                     break
  772.                    
  773.             /*
  774.             function IsBlankForList (fieldvalue ,fieldtext)
  775.             Description:  Is used to check for blank value for drop down fields
  776.             */     
  777.         case "IsBlankForList":
  778.                  var fieldVal=webForm[fieldDet[i][0]]
  779.                   if(fieldVal.options[fieldVal.selectedIndex].text=="" || fieldVal.options[fieldVal.selectedIndex].text=="----- Please Select -----")
  780.                         {
  781.                     alert("Please Select "+ fieldDet[i][1])
  782.                     webForm[fieldDet[i][0]].focus();
  783.                     return 1;
  784.                     }
  785.  
  786.                  break
  787.        
  788.  
  789. /*checks if the entered data is     TEXT ONLY not number or special char or blank (sam)*/
  790.        
  791.         case "textOnly":
  792.        
  793.         var fieldVal=webForm[fieldDet[i][0]]
  794.         if(fieldVal.value.match("[^A-Za-z ]" ))
  795.         {
  796.             alert("The values in this field "+fieldDet[i][1]+ " should be alphabetic only")
  797.             webForm[fieldDet[i][0]].value="";
  798.             webForm[fieldDet[i][0]].focus();
  799.             return 1;
  800.         }
  801.        
  802.         break
  803. ////////////////////////////////////////
  804.  
  805.         /* validation for radio button (sam)*/ 
  806.         case "radioVal":
  807.         var fieldVal=webForm[fieldDet[i][0]]   
  808.         var cnt = -1;
  809.         for (var j=fieldVal.length-1; j > -1; j--)
  810.         {  
  811.             if (fieldVal[j].checked)
  812.                 {  
  813.                     cnt = j;
  814.                      j = -1;
  815.                    
  816.                 } //if
  817.         } //for    
  818.             if (cnt == -1)
  819.                 {
  820.                 alert("Please Select "+fieldDet[i][1])
  821.                 //webForm[fieldDet[i][0]].focus();
  822.                
  823.                 return 1;
  824.                 //alert("2");
  825.                     }
  826.                    
  827.             //alert("3");
  828.                     break
  829. ////////////////////////////////////////////////////////// 
  830.  
  831.             /*
  832.             function Lengthcheck(fieldvalue, fieldText, reqlength)
  833.             Description:  This function is used to check the length of a string.
  834.             */
  835.         case "Lengthcheck":
  836.                
  837.                     if (webForm[fieldDet[i][0]].value.length > fieldDet[i][3])
  838.                     {
  839.                         alert(fieldDet[i][1] + " should be less than or equal to "+ fieldDet[i][3] +"  characters")
  840.                         webForm[fieldDet[i][0]].value="";
  841.                         webForm[fieldDet[i][0]].focus();
  842.                         return 1;
  843.                         }
  844.                 break      
  845.             /*
  846.             function EmailCheck(str)
  847.             Description:  Is used to check whether string is a email id
  848.             */ 
  849.         case "EmailCheck":
  850.  
  851.                 var at="@"
  852.                 var dot="."
  853.                 var lat=webForm[fieldDet[i][0]].value.indexOf(at)
  854.                 var lstr=webForm[fieldDet[i][0]].value.length
  855.                 var ldot=webForm[fieldDet[i][0]].value.indexOf(dot)
  856.                 if (webForm[fieldDet[i][0]].value.indexOf(at)==-1)
  857.                     {
  858.                        alert("Please Enter valid " + fieldDet[i][1])
  859.                        webForm[fieldDet[i][0]].value="";
  860.                        webForm[fieldDet[i][0]].focus();
  861.                        return 1;
  862.                     }
  863.  
  864.                 if (webForm[fieldDet[i][0]].value.indexOf(at)==-1 || webForm[fieldDet[i][0]].value.indexOf(at)==0 || webForm[fieldDet[i][0]].value.indexOf(at)==lstr)
  865.                     {
  866.                        alert("Please Enter valid " + fieldDet[i][1])
  867.                         webForm[fieldDet[i][0]].value="";
  868.                        webForm[fieldDet[i][0]].focus();
  869.                        return 1;
  870.                     }
  871.  
  872.                 if (webForm[fieldDet[i][0]].value.indexOf(dot)==-1 || webForm[fieldDet[i][0]].value.indexOf(dot)==0 || webForm[fieldDet[i][0]].value.indexOf(dot)==lstr)
  873.                     {
  874.                       alert("Please Enter valid " + fieldDet[i][1])
  875.                       webForm[fieldDet[i][0]].value="";
  876.                       webForm[fieldDet[i][0]].focus();
  877.                         return 1;
  878.                     }
  879.        
  880.                  if (webForm[fieldDet[i][0]].value.indexOf(at,(lat+1))!=-1)
  881.                     {
  882.                        alert("Please Enter valid " + fieldDet[i][1])
  883.                        webForm[fieldDet[i][0]].value="";
  884.                        webForm[fieldDet[i][0]].focus();
  885.                         return 1;
  886.                       }
  887.        
  888.                  if (webForm[fieldDet[i][0]].value.substring(lat-1,lat)==dot || webForm[fieldDet[i][0]].value.substring(lat+1,lat+2)==dot)
  889.                     {
  890.                         alert("Please Enter valid " + fieldDet[i][1])
  891.                         webForm[fieldDet[i][0]].value="";
  892.                         webForm[fieldDet[i][0]].focus();
  893.                         return 1;
  894.                      }
  895.        
  896.                  if (webForm[fieldDet[i][0]].value.indexOf(dot,(lat+2))==-1)
  897.                     {
  898.                        alert("Please Enter valid " + fieldDet[i][1])
  899.                        webForm[fieldDet[i][0]].value="";
  900.                        webForm[fieldDet[i][0]].focus();
  901.                         return 1;
  902.                     }
  903.            
  904.                  if (webForm[fieldDet[i][0]].value.indexOf(" ")!=-1)
  905.                     {
  906.                         alert("Please Enter valid " + fieldDet[i][1])
  907.                         webForm[fieldDet[i][0]].value="";
  908.                         webForm[fieldDet[i][0]].focus();
  909.                             return 1;
  910.                       }
  911.  
  912.                  break
  913.  
  914.                 /*
  915.                 function StringLength(fieldvalue , fieldtext,length)
  916.                 Description:  This function is used to check the length of a string.
  917.                 */
  918.         case "StringLength":
  919.                 // alert(webForm[fieldDet[i][0]].value.length)
  920.                     if((Trim(webForm[fieldDet[i][0]].value).length) > fieldDet[i][3])
  921.                      {
  922. //                          alert(webForm[fieldDet[i][0]].value.length)                        
  923.                            alert(fieldDet[i][1] + " should be less than or equal to "+ fieldDet[i][3] +"  characters");
  924.                            webForm[fieldDet[i][0]].value="";
  925.                            webForm[fieldDet[i][0]].focus();
  926.                         return 1;       // to indicate in the calling function that error has occurred.
  927.                      }
  928.                      
  929.            
  930.                 break
  931.  
  932.             /*
  933.             function StartDateCheckGreat(startdate,FieldText)
  934.             Description:  This Function checks if start date is less than equal to current date
  935.             */
  936.     case "StartDateCheckGreat":
  937.  
  938.                 var dateVal = webForm[fieldDet[i][0]].value.split("/",3)
  939.                 var dateStr=dateVal[1]+"/"+dateVal[0]+"/"+dateVal[2]
  940.                
  941.                 var tmpDate = Date.parse(dateStr)
  942.                  
  943.                 var today=new Date()
  944.                  
  945.                 var dd=today.getUTCDate()  
  946.                 var mm=today.getUTCMonth()
  947.                  mm=mm+1
  948.                  var yy=today.getUTCFullYear()
  949.                 var todayStr= mm+"/"+dd+"/"+yy
  950.                  
  951.                 var todayDate=Date.parse(todayStr)
  952.                
  953.                 if(tmpDate < todayDate)
  954.                 {  
  955.                    
  956.                     alert(Field[i][1] + " should be less than Current Date");
  957.                     webForm[fieldDet[i][0]].value="";
  958.                     webForm[fieldDet[i][0]].focus();
  959.                     return 1;
  960.                 }
  961.  
  962.                 break
  963.  
  964.             /*
  965.             function DateCheck(startdate,enddate,FieldText,FieldText1)
  966.             Description:  This Function checks if start date is greater than end date
  967.             */
  968.        
  969.        case "DateCheck":
  970.                
  971.                 var startDateVal = webForm[fieldDet[i][0]].value.split("/",3);
  972.                 var startDateStr=startDateVal[1]+"/"+startDateVal[0]+"/"+startDateVal[2]
  973.  
  974.                  var startDate=Date.parse(startDateStr)
  975.  
  976.                 var endDateVal = webForm[fieldDet[i][3]].value.split("/",3);
  977.                 var endDateStr = endDateVal[1]+"/"+endDateVal[0]+"/"+endDateVal[2];
  978.  
  979.                 var endDate=Date.parse(endDateStr)
  980.  
  981.                 if(endDate < startDate)
  982.                 {  
  983.                 alert(fieldDet[i][1] + " can not be greater than End Date" ); //" + fieldDet[i][3]
  984.                 webForm[fieldDet[i][3]].value="";
  985.                 webForm[fieldDet[i][3]].focus();
  986.                 return 1;
  987.                 }
  988.  
  989.                 /*
  990.                 function dateDifference(fieldvalue,fieldvalue)
  991.                 {
  992.                 var date1=new Date(form.date_1.value)
  993.                 var date2 = new Date(f.date_2.value)
  994.                 var one_day=1000*60*60*24
  995.                 f.noofdate.value=(Math.ceil((date1.getTime()-date2.getTime())/(one_day))+1+
  996.                 " Days difference");
  997.                 return true
  998.                 }
  999.                 */     
  1000.             break
  1001.    
  1002.             /*
  1003.             function StartDateCheckForGreat(startdate,FieldText)
  1004.             Description:  This Function checks if start date is greater than equal than current date
  1005.             */
  1006.     case "StartDateCheckLess":
  1007.  
  1008.             var dateVal = webForm[fieldDet[i][0]].value.split("/",3)
  1009.             var dateStr=dateVal[1]+"/"+dateVal[0]+"/"+dateVal[2]
  1010.  
  1011.             var tmpDate = Date.parse(dateStr)
  1012.  
  1013.              var today=new Date()
  1014.              var dd=today.getUTCDate()
  1015.             var mm=today.getUTCMonth()
  1016.              mm=mm+1
  1017.              var yy=today.getUTCFullYear()
  1018.            
  1019.             var todayStr= mm+"/"+dd+"/"+yy
  1020.              
  1021.             var todayDate =Date.parse(todayStr)
  1022.            
  1023.             if( tmpDate > todayDate)
  1024.             {  
  1025.                 alert( fieldDet[i][0]+ " should be greater than Current Date");
  1026.                 webForm[fieldDet[i][0]].value="";
  1027.                 webForm[fieldDet[i][0]].focus();
  1028.                 return 1;
  1029.             }
  1030.            
  1031.             break
  1032. case "StartDateCheckHigh":
  1033.  
  1034.             var dateVal = webForm[fieldDet[i][0]].value.split("/",3)
  1035.             var dateStr=dateVal[1]+"/"+dateVal[0]+"/"+dateVal[2]
  1036.  
  1037.             var tmpDate = Date.parse(dateStr)
  1038.  
  1039.              var today=new Date()
  1040.              var dd=today.getUTCDate()
  1041.             var mm=today.getUTCMonth()
  1042.              mm=mm+1
  1043.              var yy=today.getUTCFullYear()
  1044.            
  1045.             var todayStr= mm+"/"+dd+"/"+yy
  1046.              
  1047.             var todayDate =Date.parse(todayStr)
  1048.            
  1049.             if( tmpDate < todayDate)
  1050.             {  
  1051.                 alert( fieldDet[i][1]+ " should not be less than Current Date");
  1052.                 webForm[fieldDet[i][0]].value="";
  1053.                 webForm[fieldDet[i][0]].focus();
  1054.                 return 1;
  1055.             }
  1056.            
  1057.             break
  1058.  
  1059.     case "CheckFileName":
  1060.    
  1061.         function checkfilename()
  1062.         {
  1063.            
  1064.             var allfields=webForm.elements.length
  1065.             //alert(allfields) 
  1066.             var fieldtype
  1067.             var fieldvalue
  1068.             for(i=0;i<allfields;i++)
  1069.             {
  1070.               fieldtype=webForm.elements[i].type
  1071.               //alert(fieldtype)
  1072.               fieldvalue=webForm.elements[i].value
  1073.               //alert(fieldvalue)
  1074.               if(fieldtype=="file")
  1075.                break
  1076.               }
  1077.             // check for blank file path
  1078.               if(fieldvalue=="")
  1079.               {
  1080.                   alert("Please select file")
  1081.                   return false
  1082.               }
  1083.               else
  1084.               {
  1085.                // check for bad characters in file path
  1086.                var start=fieldvalue.lastIndexOf("\\")+1
  1087.                end=fieldvalue.length
  1088.                var filename=fieldvalue.slice(start,end)
  1089.               var badchars=" !"+'"'+"£$%^&*()+'/\?,@`|¬"
  1090.             var check  
  1091.             for(c=0;c<badchars.length;c++)
  1092.             {  
  1093.                check=filename.indexOf(badchars.substring(c,c+1))
  1094.                 if(check != -1)
  1095.                 {
  1096.                   alert("Not a valid file name."+check)
  1097.                   return false
  1098.                  }
  1099.      
  1100.                 }  
  1101.  
  1102.             }
  1103.               return true
  1104.             }
  1105.  
  1106.     break
  1107.    
  1108.             /*
  1109.             function ContainsSpecialChar(str)
  1110.             Description:  Is used to check whether string contains a special charecter
  1111.             */ 
  1112.     case "ContainsSpecialChar":
  1113.    
  1114.            
  1115.                  var iChars = "`~!@#$%^*()+=\\[]';,{}|\":<>?";
  1116.              var isPresent = 0;
  1117.             // alert("function sp chars")
  1118.             //var temp=
  1119.             //alert(temp.length)
  1120.             for (var j = 0; j < webForm[fieldDet[i][0]].value.length; j++)
  1121.                 {
  1122.                 //      alert(webForm[fieldDet[i][0]].value)  
  1123.                     if (iChars.indexOf(webForm[fieldDet[i][0]].value.charAt(j)) != -1)
  1124.                     {
  1125.                         alert (fieldDet[i][1] + " could not contain special characters");
  1126.                         webForm[fieldDet[i][0]].value="";
  1127.                         webForm[fieldDet[i][0]].focus();
  1128.                         return 1
  1129.                     }
  1130.                 }
  1131.    
  1132.             break
  1133.    
  1134.             /*
  1135.              function AlphaNumeric(alphane)
  1136.             Description:  Is used to validate Alphanumeric value
  1137.             */ 
  1138.         case "AlphaNumeric":
  1139.  
  1140.                 var numeric = webForm[fieldDet[i][0]].value;
  1141.                 for(var j=0; j<numeric.length; j++)
  1142.                 {
  1143.                       var alphaa = numeric.charAt(j);
  1144.                       var hh = alphaa.charCodeAt(0);
  1145.                       if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
  1146.                         {
  1147.                             alert("Please Enter Alpha Numeric Value in "+ fieldDet[i][1] )
  1148.                             webForm[fieldDet[i][0]].value="";
  1149.                             webForm[fieldDet[i][0]].focus();
  1150.                             return 1
  1151.                         }
  1152.                 }
  1153.              
  1154.             break
  1155.                         /*
  1156.             function UniqueCheck (fieldvalue, fieldtext ,valueList)
  1157.             Description : Is used to check uniqueness of thye entry
  1158.             */
  1159.  
  1160.     case "UniqueCheck":
  1161.            
  1162.             var length,temp
  1163.             var i,exist
  1164.  
  1165.             var arr=new Array();
  1166.  
  1167.             arr = webForm[fieldDet[i][3]].value.split(", ")
  1168.             length = arr.length
  1169.                    
  1170.             if(webForm[fieldDet[i][0]].type=="select-one")
  1171.             {
  1172.                 temp=Trim(webForm[fieldDet[i][0]].options[webForm[fieldDet[i][0]].selectedIndex].text)
  1173.                
  1174.             }
  1175.             else
  1176.             {
  1177.                 temp=Trim(webForm[fieldDet[i][0]].value)
  1178.                
  1179.             }
  1180.  
  1181.              for(j=0;j<length;j++)
  1182.                 {
  1183.                         if(Trim(temp.toLowerCase())==Trim(arr[j].toLowerCase()))
  1184.                         {
  1185.                             alert(fieldDet[i][1]+" \""+temp+"\"  Already Exists")
  1186.                             webForm[fieldDet[i][0]].value="";
  1187.                             webForm[fieldDet[i][0]].focus();
  1188.                             return 1;
  1189.                          }
  1190.    
  1191.                     }
  1192.                
  1193.             break
  1194.            
  1195.             case "UniqueCheckForSingleDOC":
  1196.            
  1197.                 if(webForm[fieldDet[i][0]].value!="" )
  1198.                 {
  1199.                     alert(fieldDet[i][1] + " Should Contain Single Document")
  1200.                     return 1
  1201.                 }
  1202.                            
  1203.             break
  1204.        
  1205.         } // end of switch loop
  1206.  
  1207.  
  1208.     } // end of for loop
  1209.  
  1210.     return 0;
  1211. } // end of validate function
  1212. function IsBlankForDialogList(fieldValue , fieldText )
  1213. {
  1214. if(webForm.dlNetworkDomain.selectedIndex==-1)
  1215.         {
  1216.         alert("Please select " + fieldText)
  1217.         return 1
  1218.         }
  1219.        
  1220.       return 0;
  1221. }
  1222.  
  1223. function BuildSummaryTable(webForm,fieldName,SummaryTableId)
  1224. {            
  1225.             var actTakenOn=new Array()
  1226.             var userName=new Array()
  1227.                        
  1228.             actTakenOn = webForm[fieldName[0]].value.split("!#")
  1229.             userName = webForm[fieldName[1]].value.split("!#")
  1230.            
  1231.             for(i=1;i<actTakenOn.length;i++)
  1232.             {  
  1233.                
  1234.                 var row=document.getElementById(SummaryTableId).insertRow(-1)
  1235.                 var actTakenOnCell=row.insertCell(-1)
  1236.                 var userNameCell=row.insertCell(-1)
  1237.                
  1238.                 actTakenOnCell.className="DynamicTableRevokeCell"
  1239.                 actTakenOnCell.innerHTML=actTakenOn[i]
  1240.                
  1241.                 actTakenOnCell.width= 50
  1242.                 userNameCell.width=150
  1243.                
  1244.                 userNameCell.className="DynamicTableRevokeCell"
  1245.                 userNameCell.innerHTML=(userName[i])
  1246.                
  1247.             }
  1248.        
  1249. }
  1250. //----------For CheckBox disabled & Checked-------------------
  1251. function readOnlyCheckBox()
  1252. {
  1253.     return false;
  1254. }
  1255.  
  1256. function validateFileupload(fileid)
  1257. {
  1258.  
  1259.  var Fileval=  document.getElementById(fileid).value
  1260.  var Slash = "\\";
  1261.  if((Fileval.substring(0,1)!="" &&Fileval.substring(1,2)==":" &&Fileval.substring(2,3)==Slash .substring(0,1))|| Fileval=="")
  1262. {
  1263. return 0
  1264. }
  1265. else
  1266. {
  1267. return 1
  1268. }
  1269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement