JavaScripts for Global Functions

 

Expand/Collapse all Show/Hide All

The table below contains information about JavaScripts in the Common.js file that can be used for global functions.

 

Expand/Collapse item  CheckRequired

Function

CheckRequired(this Form)

Purpose

This routine verifies that all required fields are fulfilled before actually submitting the form. All fields are checked and then a single error message appears listing all fields that require data.

To indicate which fields are required, the ID property must be added to the data object and assigned a "required" value (case sensitive). The name property should be something understandable by the user because the value is used in the error message if the field is null.

Parameters

thisForm    The form is being processed.

Example

In object:  <INPUT TYPE="text" NAME="CustomerName" SIZE="25" ID="required">

In the form tag:  <FORM NAME="InputForm" onSubmit="return (CheckRequired(this)">

This example returns the value of FALSE if any fields are required and are null. TRUE is returned if all required fields are fulfilled.

 

Expand/Collapse item  IsRequired

Function

IsRequired(gField)

Purpose

This routine verifies that data is entered before allowing the user to move to the next field.

Parameters

gField    The form object to validate

Example

<INPUT TYPE="CSSNAME" TYPE= "text" SIZE="23" on Blur="Isrequired(CSSNAME)">

This example returns the value of FALSE if the field is required and it is null. TRUE is returned if the required field is fulfilled.

 

Expand/Collapse item ReplaceString

Function

ReplaceString(gField, lookFor, replaceWith)

Purpose

This routine finds the lookFor value within the data and replaces the substring with the value supplied in the replaceWith substring.

Parameters

gField    The field object to validate.
lookFor    The string to be replaced within the data.
replaceWith    The string to be submitted for the substring in lookFor.

Example

<INPUT TYPE="CSSNAME" TYPE= "text" SIZE="23" onChange="ReplaceString(CSSNAME,’ ‘,’/’)>

The substring "." is searched for and replaced with "/". The example results in: 01.01.99 which is changed to 01/01/99.

 

Expand/Collapse item  CheckEmail

Function

CheckEmail(gField)

Purpose

This routine validates the e-mail address before allowing the user to leave the field.

Parameters

gField    The field object to validate.

Example

<INPUT NAME="EMAIL" TYPE="text" SIZE="23" onBlur="CheckEmail(EMAIL)">

If the entry does not contain the proper e-mail syntax, the user is returned to the data field

 

Expand/Collapse item  FmtAlpha

Function

FmtAlphal(strData, fmtCode)

Purpose

This routine formats the string supplied according to the specified format code.

Parameters

strData    The string to format.
fmtCode    Code representing the type of formatting.

fmtCode=1    Format as Upper Case
fmtCode=2    Format as Lower Case
fmtCode=3    Format as Title Case

Example

NewStr=FmtAlpha(cust_name,"3")

The string being passed for Title Case as: WORLD GLASS COMPANY will be changed to World Glass Company.

 

Expand/Collapse item  FmtPhone

Function

FmtPhone(gField)

Purpose

This routine formats data within a field to conform to the phone format of (###) ###-#### or ###-####. If the object contains more than 10 or less than 7 numbers, the field is not formatted. No other validation is performed. Data may be delimited by space, period, "/", "-", or no delimiter.

Parameters

gField    The data object to format.

Example

<INPUT NAME="PHONE" TYPE="text" SIZE="14" onChange="return FmtPhone(PHONE)">

 

Expand/Collapse item  FmtQty

Function

FmtQty(gField, qtyDec, maxQty)

Purpose

This routine validates data within a field as numeric and performs basic decimal formatting. Data validation consists of removing spaces and commas, and checking for non-numeric characters. The quantity must be between 0 and "maxQty."

Parameters

gField     The data object to format.
qtyDec    Number of decimal places; 0 for none.
maxQty   The maximum quantity allowed for this field.

Example

<INPUT NAME=QUANTITY VALUE="98.00" onBlur="FmtQty(this,2,100000000)">

 

Expand/Collapse item  ValidDate

Function

ValidDate(gField, delim, "~~y2k$~~’,’~~yr_disp$~~’)

Purpose

This routine takes data from a date object and verifies that the date is valid. This routine has considerations for leap years, maximum number of days in each month and is Y2K compliant with the 4 digit year being returned.

If the month entered is greater than 12 or less than 1, or there are alpha characters found in the date, an error message displays. If the wrong last day of the month is entered, the date is automatically corrected to the correct last day of the month.

Parameters

gField The field object to validate.
delim The standard delimiter to use for dates.
~~y2k$~~ The value of this variable, a standard Sage 100 variable that is set within the init block by the merge process. It contains the  starting year that is to be considered for the year 2000 when  a 2-digit year is entered.

~~yr_disp$~~ The value of this variable is set within the init block by the  merge process. It will contain a "C" to display the year as
 4 digits and a "Y" to display the year as 2 digits.

Example

<INPUT NAME="CSSDATE" TYPE="text" SIZE="11" onChange="ValidDate(CSSDATE,’/’,’~~y2k$~~’,’~~yr_disp$~~’)">

In the example, dates are changed as follows:

01.01.99 changed to 01/01/1999
01 01 99 changed to 01/01/1999
01-01-99 changed to 01/01/1999
01/01/99 changed to 01/01/1999
02-30-01 changed to 02/28/2001
02-30-04 changed to 02/29/2004

Dates entered with a year less than~~y2k$~~ are assumed to be the years 2000+.

 

Expand/Collapse item  DateIsLater

Function

DateIsLater(gFieldLgDate, gFieldSmDate, ‘~~y2k$~~’)

Purpose

This routine compares two dates and verifies that the later date field is later than the earlier date field.

Parameters

gFieldLgDate    The field object that is to contain the LATER or equal date.
gFieldSmDate   The field object that is to contain the EARLIER date.
~~y2k$~~         The value of this standard Sage 100 variable is set within the  init block by the merge process. It contains the starting year  that is to be considered for the year 2000 when a 2-digit year  is entered.

Example

<INPUT NAME="END DATE" TYPE="text" SIZE="11" onBlur="DateIsLater(END_DATE, START_DATE)">

 

Expand/Collapse item  FieldIsLarger

Function

FieldIsLarger(gFieldLgData, qFieldSmData,)

Purpose

This routine compares two fields (either string or numeric) and validates that the large data field is larger than the smaller data field.

Parameters

gFieldLgData    The field object that is to contain the LARGER or equal date.
qFieldSmDate   The field object that is to contain the SMALLER date.

Example

<INPUT NAME="END_INVOICE" TYPE="text" SIZE="11" onBlur="FieldIsLarger(END_INVOICE, START_INVOICE)">

 

Expand/Collapse item  MAS90PadStr

Function

MAS90PadStr(gField, fieldLen)

Purpose

This routine pads numeric strings with preceding zeros to the total length specified. If the field passed is not numeric, the data is returned in all upper case.

Parameters

gField    The field object that contains the data.
fieldLen  The total length of the field when data is returned.

Example

<INPUT NAME="INVOICE" TYPE="text" SIZE="11" onBlur="MAS90PadStr(INVOICE 7)">

 

Expand/Collapse item  openPopupWindow

Function

openPopupWindow(url, winWidth, winHeight)

Purpose

This routine opens a generic window for displaying HTML pages.

Parameters

url    The URL of the HTML page to be displayed in the window.
winWidth    The width of the window display in pixels.
winHeight    The height of the window display in pixels.

Example

<INPUT NAME="SEARCH" TYPE="button" onClick="openPopupWindow('http://www.sota.com/Search.htm',460,160)">

 

Expand/Collapse item  ClosePopupWindow

Function

closePopupWindow( )

Purpose

This routine closes the previously opened window. A global variable named "popupWinOpen"must be set to "0" before this function is called.

Parameters

None required.

Example

<INPUT NAME="SEARCH" TYPE="button" onClick="closePopupWindow()">

 

Expand/Collapse item  setForms

Function

SetForms

Purpose

This routine can be used to set the initial value of UDF check boxes and list boxes. The function must be added to the HTML code of the applicable template as an onLoad event handler in the <BODY> tag so that the function performs immediately after the page loads.

The function can automatically set the attributes for a check box and list box UDFs to be initially checked and selected. Store the initial value (Y or N) of the UDF in a hidden form object immediately preceding the check box or list box tags. The name of the object is not important; however, it should be unique to the form. The multiple select option is not supported because a UDF will not contain multiple values in Sage 100.

Parameters

No parameters required.

The following is a sample of HTML code required to use the SetForms function:

<body onLoad="SetForms()"> or

<body onLoad="SetForms();window.document.form.cust_name.focus()">

when there is already a function included on the onLoad event handler in the <body> tag

<table><form>

<tr><th class=introw align="right">Example of ML Input:</th>

<td class=datarow><input type="text" name="Ml_udf_itc_sample" value="~~Ml_udf_itc_sample$~~" ></td></tr>

<tr><th class=introw align="right">Example of CB Input:</th>

<td class=datarow><input type="hidden" name="CB_init_val" value="~~CB_udf_itc_cb_sample$~~" >

<input type="checkbox" name="CB_udf_itc_cb_sample"></td></tr> 

<tr><th class=introw align="right">Example of LB Input:</th>

<td class=datarow><input type="hidden" name="LB_init_val" value="~~Ml_udf_itc_lb_sample$~~">

<select name="Ml_udf_itc_lb_sample">

<option value="BROWN">Brown

<option value="BLUE">Blue

<option value="RED">Red

<option value="GREEN">Green

</select></td></tr>

</form></table>

</body>

 

For more information, see:

Using eBusiness Manager JavaScripts

JavaScripts for Menu Functions


 

© Sage Group plc 2019. Privacy Policy | Copyright/Trademarks