India seo web development website designer freelance

insertObject()

Availability

MX

Description

Required if objectTag() is not defined. Called when the user clicks OK; either inserts code into the user's document and dismisses the dialog box, or displays an error message and leaves the dialog box open. This works as an alternate function to use in objects instead of objectTag() . It does not assume that the user is inserting text at the current insertion point and allows for data validation when the user clicks OK. You should use insertObject() if one of the following conditions exists:

If none of these conditions apply, use objectTag() .

Arguments

None.

Returns

expects a string that contains an error message or an empty string. If it returns an empty string, the Object dialog box closes when the user clicks OK. If it is not empty, displays the error message and the dialog box remains.

Enabler

canInsertObject()

Example

function insertObject() { var theForm = document.forms[0]; var nameVal = theForm.firstField.value; var passwordVal = theForm.secondField.value; var errMsg = "", var isValid = true; // ensure that field values are complete and valid if (nameVal == "" || passwordVal == "") { errMsg = "Complete all values or click Cancel." } else if (nameVal.length < 4 || passwordVal.length < 6) { errMsg = "Your name must be at least four characters, and your password at least six"; } if (!errMsg) { // do some document manipulation here. Exercise left to the reader } return errMsg; }

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

India web developer website development India