logo

New Response

« Return to the main article

You are replying to:

  1. With elements on a form, you can go after names as if they were numbers in an array. For example, given: <pre>var thisform = document.forms[0];</pre> then if the first element on the form is a field named "FirstField" then it can be accessed using any of the following: <pre>thisform[0] thisform.FirstField thisform["FirstField"] thisform["First" + "Field"]</pre> So to access fields Quantity1 through Quantity7 and make sure they aren't blank...

    [<pre>]function validateFields( oForm ) { //var oForm is the form object for ( var i = 1; i < 7; i ++) { oField = oForm["Quantity" + i]; if ( oField.value.length == 0 ) { alert( 'You need to enter a value field ' + field.name ); return false; } } }[</pre>]

    This script compares the length to zero instead of the value to "" because, at least in LotusScript, it's faster that way. I have no idea whether or not it's faster for java-script.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: