Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

problems using Javascript with CDML

Featured Replies

  • Newbies

I want to limit the number of characters a user can enter into a text area on a form. before i put any scripts on my form when the user edits the fields and clicks update, everything works well and the db fields are updated. However once i put the javascript to limit the number of characters in my textarea and then submit the form i get an "unknown error number 102". I know filemaker says this error is about incorrect links or field names but not in this case. Below is the javascript that i have used:

<head>

<script language="javascript" type="text/javascript">

function limitText(limitField, limitCount, limitNum){

if (limitField.value.length > limitNum){

limitField.value = limitField.value.substring(0,limitNum);

}else {

limitCount.value = limitNum - limitField.value.length;

}

}

</script>

</head>

<body>

<table>

<tr>

<td class="style1"><div align="right">Contents</div></td>

<td><textarea name="limitedtextarea" onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,100);" onKeyUp="limitText(this.form.limitedtextarea,this.form.countdown,100);">[FMP-field:drivingsection]</textarea><br>

<font size="1">(Maximum characters: 100)<br>You have <input readonly type="text" name="countdown" size="3" value"100"> characters left.</font></td>

</tr>

Once i put this javascript in the textarea tag i get the error. Has anyone come across this before? Or know of another way i can limit a textarea....the ultimate goal is to limit it to a certain amount of characters based on contents of another field. I have just started with limiting it to 100 characters to test if it would work. Unfortunetly, it doesnt.

Any help much appreciated....

This is one that I use:

<tr><td>Establishment Description:<br>(Limited to 350 characters, approx 60 words)</td>

		<td colspan="2"><textarea name="estab_desc" cols="38" rows="4"><?php echo  $estab_desc ?></textarea></td></tr>


And the Javascript in the <head>
<script>

		function validate()

			{

			with (document.estabfm)

				{

				var subOK = true;

				sEstab_Desc = estab_desc.value;

				if (sEstab_Desc.length > 350)

						{ 

						subOK = false;

						alert ("The Description is " + estab_desc.value.length + " characters longnPlease shorten!!!");

						};

						

				if (subOK) { submit(); };

				};

			};

</script>

I use this in the <form> tag:

onsubmit="validate();return false;">

Remember that this:

name="limitedtextarea"

must be a name of one of the fields in your database.

Garry

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.