urgent help needed

Results 1 to 3 of 3

Thread: urgent help needed

  1. #1
    rupali Guest

    Default urgent help needed

    i have a jsscript file that include all the validation that is required in the file the code is<BR><BR><BR>function trimStr(strVal){<BR>// trim leading and trailing spaces from the string value.<BR> var start = 0;<BR> var end = strVal.length;<BR> strVal = strVal + "!";<BR><BR> // find first non space char.<BR> for (start = 0 ; strVal.substring(start , start+1) == " " ; start++);<BR><BR> if (start &#060; end) {<BR> // find last space.<BR> for (end = end ; strVal.substring(end-1 , end) == " " ; end--);<BR><BR> return strVal.substring(start, end);<BR> }<BR> else {<BR> return "";<BR> }<BR>}<BR><BR>function getRadioValue(radioObject){<BR>/* Return the value of the radio button */<BR>/* */<BR> var v = "" ;<BR> var i = 0;<BR> var numelements = 0;<BR><BR>/* radioObject = formObject.eval("this." + form_name + "." + radioName);*/<BR><BR> numelements = radioObject.length;<BR> for (i = 0 ; i &#060; numelements ; i++) {<BR> if (radioObject[i].checked == true) {<BR> v = radioObject[i].value;<BR> }<BR> }<BR> return v;<BR>}<BR><BR><BR>function subFieldValidation(formObject) {<BR>/* Validate fields on a form */<BR>/* first get the fields to be validated. */<BR> var i = 0;<BR> var sel = 0;<BR> ###PROBLem#### var fieldList = formObject.FieldValidation.value;<BR> var form_name = "";<BR><BR> flds = fieldList.split(";");<BR><BR> for (i = 0 ; i &#060; flds.length ; i++)<BR> {<BR> reqs = flds[i].split("+");<BR> /* get the current value of the field. */<BR> switch (reqs[1]) {<BR> case "radio" :<BR> fldVal = getRadioValue( eval("formObject." + reqs[0]) );<BR> break;<BR> case "keyword" :<BR> sel = eval("formObject." + reqs[0] + ".selectedIndex");<BR> if (sel == 0){<BR> fldVal = "";<BR> }<BR> else{<BR> fldVal = eval("formObject." + reqs[0] + "[" + sel + "].text");<BR> }<BR> break;<BR> case "multi-keyword" :<BR> sel = eval("formObject." + reqs[0] + ".selectedIndex");<BR> if (sel == -1){<BR> fldVal = "";<BR> }<BR> else{<BR> fldVal = eval("formObject." + reqs[0] + "[" + sel + "].text");<BR> }<BR> break;<BR> default :<BR> fldVal = eval("formObject." + reqs[0] + ".value");<BR> break;<BR> }<BR><BR>/* if (reqs[1] == "radio"){<BR> fldVal = getRadioValue( eval("formObject." + reqs[0]) );<BR> }<BR> else{<BR> fldVal = eval("formObject." + reqs[0] + ".value");<BR> } */<BR><BR> /* check if the field is empty, but should have a value. */<BR> if (trimStr(fldVal+"") == "")<BR> {<BR> if (reqs[2] == "yes")<BR> {<BR> /* inform user that they need to enter a value in this field */<BR> alert("Please enter a value for " + reqs[3]);<BR><BR> /* set the focus to the field that needs to be completed */<BR> if (reqs[1] == "radio"){<BR> eval("formObject." + reqs[0] + "[0].focus()");<BR> }<BR> else{<BR> eval("formObject." + reqs[0] + ".focus()");<BR> }<BR> return false;<BR><BR> }<BR> } <BR> else<BR> {<BR> //check the Length of the fields required. Must be checked before sent to Oracle<BR> // if the parameter of the validation field is 0, then no specific length is required<BR> var maxLengthStr = reqs[4];<BR> var maxLengthNum = parseInt(maxLengthStr);<BR> if (maxLengthStr == 0) {<BR> //no need to do a check - no length restrictions in PAC III<BR> }<BR> else{<BR> if (fldVal.length &#062; maxLengthNum) {<BR> alert(reqs[3] + " should be a max of " + reqs[4] + " characters, please rectify") ;<BR> eval("formObject." + reqs[0] + ".focus()");<BR> return false; <BR> }<BR> }<BR> /* check the type of field */<BR> if (reqs[1] == "num")<BR> {<BR> n = parseInt(fldVal)<BR> if (isNaN(n))<BR> {<BR> alert("The value for " + reqs[3] + " should be numeric");<BR> eval("formObject." + reqs[0] + ".focus()");<BR> return false;<BR> }<BR> }<BR><BR> } /* end of if fldVal == "" */<BR> } /* end of for */<BR> //<BR> //------------------------------------------------------------------<BR> // 2. ENSURE THE END DATE (IF AVAIL) IS NOT BEFORE THE START DATE<BR> //------------------------------------------------------------------<BR> // 1st check they have entered a Start & End Date <BR><BR><BR> //These VARS NEED to be re-set everytime in case user enters a Date, then removes a date, then re-enters one<BR> var resourceStart = "" ;<BR> var resourceEnd = "" ;<BR> //<BR> //<BR> //FIRST CHECK THE START & END DATES HAVE BEEN ENTERED<BR> //<BR> if (formObject.InitiationDate.value == "" &#124&#124 formObject.TerminationDate.value == "") {<BR> alert("You must enter Start AND End Dates for the Resource");<BR> return false;<BR> }<BR> // * SET THE START DATE TO A JAVASCRIPT DATE VARIABLE (READY TO COMPARE THE 2)<BR> var resourceStartDate = new String(formObject.InitiationDate.value)<BR> var dayNo; dayNo = resourceStartDate.substring(0, resourceStartDate.indexOf("/")) ;<BR> var monthNoa; monthNoa = resourceStartDate.substring(resourceStartDate.inde xOf("/")+1, resourceStartDate.lastIndexOf("/")) ;<BR> var monthNo; monthNo = monthNoa - 1 ;<BR> var yearNo; yearNo = resourceStartDate.substring(resourceStartDate.last IndexOf("/")+1) ;<BR> resourceStart = new Date(yearNo, monthNo, dayNo)<BR> // * SET THE END DATE TO A JAVASCRIPT DATE VARIABLE (READY TO COMPARE THE 2)<BR> var resourceEndDate = new String(formObject.TerminationDate.value)<BR> var dayNo; dayNo = resourceEndDate.substring(0, resourceEndDate.indexOf("/")) ;<BR> // VERY ODD HAPPENINGS HERE<BR> var monthNoa; monthNoa = resourceEndDate.substring(resourceEndDate.indexOf( "/")+1, resourceEndDate.lastIndexOf("/")) ;<BR> var monthNo; monthNo = monthNoa -1;<BR> var yearNo; yearNo = resourceEndDate.substring(resourceEndDate.lastInde xOf("/")+1) ;<BR> resourceEnd = new Date(yearNo, monthNo, dayNo) ; <BR> //NOW COMPARE WHETHER END DATE IS BEFORE THE START DATE<BR> if (resourceStart &#062;= resourceEnd) {<BR> alert("The Resource End Date entered must be AFTER the Resource Start Date") ;<BR> return false ;<BR> }<BR> return true;<BR>}<BR>iam including the function subfieldvalidation(this) in the form tag by passing this argument so that it can recognise form object<BR>but where ihave marked #####problem######## is giving me aproblem error is fieldvaliation.value is not an object in text box iam calling strtrim(text1) function how to do that <BR><BR>please help<BR>

  2. #2
    Join Date
    Dec 1969

    Default CODE DUMP

    please - if yo have a problem with one function - only show one function.<BR><BR>I&#039;m not even going to look at this.<BR><BR>j

  3. #3
    Mike Shaffer Guest

    Default RE: urgent help needed

    Well... you showed us a bunch of javascript code, but none of the HTML code for which it is intended, so I can&#039;t give you a definitive answer. However, it sounds like perhaps you do not have any field in your form named (specifically) FieldValidation. Is that possible?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts