Skip 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.

Need JavaScript Assistance with FM Form Validation

Featured Replies

  • Newbies

Ok,

I've been hacking at this for a while...and it's very annoying...

I've got a simple database I'm trying to have users "login" by verifying they're in

the database with 3 pieces of information.

Don't get me started about a single unique identifier -- the client wants it this way...

FMP will find against any field that's entered, even if the others are empty. So, to try and

counter this I turned to JavaScript - at which I'm admittedly a novice...so I searched the

web and webmonkey had a script that seemed to do the trick...

Then, getting the form to work with the WebCompanion properly is now my problem.

I've seen 2 references to making things happen upon form submittal:

1) in the FORM tag, use the OnSubmit="return myjavascriptfunction(formname);"

2) in the button itself, use an OnClick="myjavascriptfunction("formname")

If I use method 1, it never seems to validate the submission

If I use method 2 I get the warnings that stuff is left empty...

BUT (here's my problem) - either way, with fields left empty the -Find happens anyway

and I'm taken to my format file anyway - which is not what I want to do...

Dreamweaver's Javascript reference suggests to stick with the OnSubmit in the FORM

tag, but that one doesn't seem to be running the code at all and simply lets the form

submit as if I had no JavaScript embedded at all!?!?

Any assistance you all could lend me would be greatly appreciated...

I'm trying to get this one stickler out of the way for a presentation of the web work on

Monday AM.

oh, and my apologies if the solution is posted previously and my request is redundant,

but I've been spending hours searching and reading FM Forums and haven't located it...

Thanks, in advance for any assistance...

-Ty

Below is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Login JS Test</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript">

<!--

// -----------------------------------------------------------------

// Function B) IsFormComplete

// Language : JavaScript

// Description : Checks if all elements in a form have a non-blank value

// Copyright : © 1998 Shawn Dorman

// http://www.goodnet.com/~sdorman/web/IsFormComplete.html

// -----------------------------------------------------------------

// Ver Date Description of modification

// --- ---------- --------------------------------------------------

// 1.0 08/31/1996 Original write

// 1.1 09/30/1998 CHG: Use standard header format

// -----------------------------------------------------------------

// Source: Webmonkey Code Library

// (http://www.hotwired.com/webmonkey/javascript/code_library/)

// -----------------------------------------------------------------

function IsFormComplete(FormName)

{

var x = 0

var FormOk = true

while ((x < document.forms[FormName].elements.length) && (FormOk))

{

if (document.forms[FormName].elements[x].value == '')

{

alert('Please enter the '+document.forms[FormName].elements[x].name +' and try again.')

document.forms[FormName].elements[x].focus()

FormOk = false

}

x ++

}

return FormOk

}

// -->

</script>

</head>

<body>

<form name="loginform" method="post" onSubmit="return IsFormComplete(loginform);" action="FMPro">

<INPUT TYPE="hidden" NAME="-DB" VALUE="Teachers.fp5">

<INPUT TYPE="hidden" NAME="-Format" VALUE="myinfo.htm">

<INPUT TYPE="hidden" NAME="-Error" VALUE="default2.htm">

<INPUT TYPE="hidden" NAME="-Lay" VALUE="web">

<p>Last Name: <input name="Last Name" type="text" id="Last Name">

<br>

Last 4 Digits of SSN: <input name="Last4" type="text" id="Last4">

<br>

Birthdate mm/dd/yyyy: <input name="Birthdate" type="text" id="Birthdate">

</p>

<input name="-Find" type="submit" id="-Find" value="Submit">

</form>

</body>

</html>

RE: FMP will find against any field that's entered, even if the others are empty.

Not with exact search in web security database or "==" search. Or you can make calculation field with all values.

To rely just on JS for filling form from web... hmm... what will happen if browser is with JS off?

Use JavaScript to verify that data has been entered in each field. This way a JS-pop-up on the client side tells the client to fill in the blank and no load is put on the site to return an error page. If you use JS you can always put something at your opening to filter out clients with JS turned off.

Like Anatoli recommends, use the field contents match in your form in conjunction with each data input. I posted a two line sample here in the past 10 days.

Good luck.

  • Author
  • Newbies

OK OK...

Nevermind this...I found your answer from an earlier post...

You can put the same field in the form as a hidden field with "==" as it's value...and then when it's

submitted the hidden and "real" form entry are combined to do the "==myentry" search in FMPro!

http://www.fmforums.com/threads/showflat.php?Cat=&Board=UBB22&Number=66190&Forum=UBB22&Words=field%20content%20match&Match=Entire%20Phrase&Searchpage=0&Limit=50&Old=allposts&Main=65939&Search=true#Post66190

-Ty

---------------------------------

Ok,

So, yes, with JS off...the thing reverts back to being a small pain of finding only the first match of a

multiple hits (like the guy who types SMITH for last name and leaves the other fields empty...)

Sooooo...

Nosing into the CDML reference DB says the following under the -Op tag:

>You can use any FileMaker Pro Find operator by specifying the begins with (bw) parameter. E.g.,

>To specify the "Find Content Match" (==) operator, you would specify the begins with parameter (bw)

>and then you would place the characters "==" before the actual search criteria. The required lines

>would look like this:

<input type="hidden" name="-Op" value="bw">

<input type="text" name="First" value="==Keith">

This is great, so I should present my web form with 3 boxes with "==" pre-entered into them?

This will only serve to confuse the user, and make them want to delete the equal signs...

I've at least done a -Op with a value of "eq" but that still allows for "blank/nonentry" in the boxes to go through...

I guess it's time to whip out the security databases too? Argh.

-Ty

Cheese and crackers. You must have mis-understood the syntax for a field contents match "==".

Of course, perhaps my statement that I had "posted a two line sample here in the past 10 days." misled you. By here I was referring in a broad manner to the Internet forums (I don't index my postings for the benefit of myself or others). The posting is actually in the UFO forum" here.

I trust you will find this thread useful to your understanding of the syntax.

You might also look at the various examples which are available in the Sample Files forum. Most of them are referenced with something about "web" or "CDML". And hey, good news, they are free.

Good luck in learning how to have fun with this stuff.

Re-post: or you can make calculation field with all values.

That is work in FM for 1 minute. Then in login database if that field connect through relationship with people database with the same calculation field you have valid relation and you can simply test for value in login db "yes" or "no".

This way, with login database you can analyze what visitors are trying for log and do other analysis.

DW form validation works.

Not with JavaScript OFF smile.gif

"Not with JavaScript OFF "

--well now none of this works with FM OFF...LOL laugh.gif

Great idea, FM off smile.gif

Then I can go to sleep!

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.