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.

DB on the web and validation

Featured Replies

I am building a DB for new clients to register on the web. I will use Custom web publishing. I want to be very strict with the way data is entered so that the databse will remain somehow clean. So I setup data validation for most of the fields.

How will Web Companion handle the validation ?

Will the error.html specified in the <form> be displayed if the data does not respect the validation criterias ?

Will the data make it to the DB THEN reply with a validation violation ?

This way I could make a calculation field for the error message so that the user is informed about what part of the form was wrong.

Can I handle the validation in CDML so that the error.html displays an apropriate list of field that failed validation ?

Thank you for your help

This is usually done, with Javascript, on the page with the form prior to submission. Each element of the form can be validated (and manipulated), and where apropriate an Alert box can display any errors which need to be corrected.

Garry

  • Author

hmmm... JavaScript...

Any alternative ? (I don't know JavaScript, considering learning it)

As I was suggesting in my original post, if the data makes it to the DB I can generate an error message with a calculation field which can then be shown on the error.htm...

Does that sound right ?

JavaScript is usually better, because data do not travel to the server for validation.

But the method with calc field is also not bad and I am using it quite often.

Put that check on top of the page and if it is OK then do not display warning, only Thank you. If the page/record does not validate, message at top of the page will notify visitor about problem and beneath will be the form to fill it up.

Search at www.google.com yields:

Searched the web for JavaScript. Results 1 - 10 of about 6,270,000. Search took 0.13 seconds.

  • Author

clever...

I figured there is probably a LOT of sites revolving around JS

I was wondering if any of you know where I can find specific examples of simple field validation.

But your right, it's probably not hard to find.

You will figure JavaScript in no time if you are just a bit experienced in programming. I can give you mine, but without explanation it will be probably harder to figure that out, then from some JavaScript pages.

  • Author

Sounds good but there is MANY fields in my form and it would be very useful to be able to tell the user which part of the form doesn't meet validation criterias.

Is there a way to do that with FM ?

If not, where can I find example of JavaScript field validation (it can't be too complicated !)

Thank you !

Here. I'll give you my javascript only because I hated the process of going around and figuring it out myself, taking existing code and modifying it. The best way to learn JS IS to fiddle with existing code. The example below checks a bunch of fields. It then returns, one by one, an alert message when you submit the form, of each field you incorrectly answered. For example, if you didn't fill in 3 fields, the first submit will tell you the first field you forget. If you fix it and then submit, it'll then tell you the second and so on. I'm sure there are cleaner ways than this, but here ya go. I'm giving you the example of needing the "address" field validated, but to do other fields, just copy and paste the italicized code. "FB" is the name of the form...change that as you require in the <form> tag

put this in your <head> section

<script language="JavaScript">

<!

quote:

Originally posted by CyberSport:

The example below checks a bunch of fields.

Does this validate a pop-up menu? I have a form, and the users' names are in a pop-up list. When users select their name, fill out the rest of the form, then press "submit," they get an email confirmation. If they leave the user name blank (by not selecting anything), they don't get the email confirmation. So I need validation for pop-up menus.

I know nothing about javascript, so before I cut and paste my way to a headache, is this code good for what I need?

Thanks,

Andrew

I just edited the page to make the name field a pop-up menu. As long as the first item in your value list (e.g. "select cost") has a value of "", it'll still work.

  • 2 weeks later...
  • Author

Thank you all for your help !

I now have my JS validation running smooth under IE. But for some reason, Netscape 4.79 considers a pop-up menu empty even when it is not... My JS function that checks if a field is empty is the classic :

function isEmpty (s)

{

return ((s==null) || (s.length==0))

}

The pop-up menu fails validation (in Netscape only) no matter what ! isEmpty returns false even if I select a value from the pop-up... It works fine with normal text fields !

I even tried adding the other approach :

function isEmpty (s)

{

var re = /S/;

return ((s==null) || (s.length==0) || (re.test(s) == 0))

}

Any idea ?

Thanks

p.s. I know this isn't a JS forum but it kinda fits the topic...

[ December 28, 2001: Message edited by: cinolas ]

If the contents of the parameter (s) you are passing to the function has an underscore, or space, you may have problems.

All the best.

Garry

  • Author

This menu choice is about the gender of the registering user. So the values are "Male" or "Female". No space or underscore...

No matter what I try, the JS returns empty in Netscape 4.79.

HELP !

  • Author

I got the answer from a JS forum at www.tek-tips.com.

When calling a verification function (such as isEmpty, see previous post) on the value of a pop-up menu, one must sepcify the value of the index and not the field.

SO :

if (isEmpty(document.theForm.Sex[document.theForm.Sex.selectedIndex].value))

return WarnEmpty(document.theForm.Sex, "Sex");

INSTEAD OF :

// Doesn't work in Netscape 4.79

if (isEmpty(document.theForm.Sex.value))

return WarnEmpty(document.theForm.Sex, "Sex");

Hope it helps someone else !

Thank you all for your help

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.