Input validation that uses HTML field attributes in R5

This input validation takes advantage of the HTML tab (the last one) in the R5 field properties in two ways.

This Content Component encountered an error

This input validation takes advantage of the HTML tab (the last one) in the R5 field properties in two ways.

First, it uses the other section to assign an attribute to the field(s) in question.

Second, it uses the title section to display a meaningful name for the field(s) in question.


Scenario: I have five text fields on a web form. Three of them are mandatory and require validation for non-blank entries.

Settings:
For the mandatory fields MF1, Mf2 & MF3:
1. Assign an attribute such as FT=M (Field Type=Mandatory) in the other section of the HTML field tab.
2. Enter the descriptive name of each field in the title section of the same tab. This will be used in the message displayed to the user. Example: for MF1 the descriptive tile is: Customer Creation Date

 Code (in the JS Header of the form):
function validate()
{
var f=document.forms[0]
//Loop through the elements of the form looking for fields with name=text AND Tagged with the attribute FT=M
for (i=0;i<f.length;i++)
{

//If element if a text field AND is mandatory (i.e. FT=M) AND has been left blank, capture it.
if(f.elements[i].type=="text" && f.elements[i].FT=="M" && f.elements[i].value=="")
{
alert("You must enter " + f.elements[i].title)
//Return user to offending field
f.elements[i].focus()
//terminate function
return false
break
}
}
//End of Code

The above code works equally well for a ComboBox. The field type to look for is "select-one" instead of "text."

This was first published in August 2001

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close