Tuesday, November 20, 2007

Input Validation - On Invalid, open URL

This only works on the web.

If you put something like this in Input Validation on a field:
@If( @ThisValue = "dontpanic" ;
@Failure( "[http://dontpanic82.blogspot.com/]" ) ;
@Success )

When the user writes "dontpanic" in a field with this input validation, and try to save the document, they will be redirected to my blog.

The only use-case I can think of at the top of my head is lookup-based login-forms.

..code to check username/password..
@If( authenticated ;
@Success ;
@Failure( "[/" + @WebDbName + "/login?OpenForm&error=wrong_username]" )

Another use case is maybe to limit too wide searches. A customer recently searched for *ia*, in a several CMS' and thought that the search didn't work (when I tested, the search took 3-4 minutes to complete).

If you can think of/have other ways to make use of this, please post it in the comments..


Nate said...

I wonder if you could do some AJAXy goodness here. Or cram some javascript in there?

Tony Palmer said...

how about linking to web based help or maybe corporate policies. Like just in time help!

Tommy Valand said...

The awful part about input validation is that it works more or less as $$Return ( @Failure([Message]or[WebPage]) ), only on a field to field basis.

This means that you lose the context of the form (lose all the stuff you wrote into the form). That is why I think it's probably most useful for forms that doesn't produce documents (login, search, etc.).

Bigger forms, I'd go with JavaScript validation onSubmit.

NotesSensei said...

You could....
Put the form into a frameset and put some JavaScript into the the Webpage part:

Something like

JavaScript:document.parent.frames[0].form[0].field.value = 'test';

and have an onChange event fireing...

but that is VERY theortetical ;-)

Or you can spit out JS that loads an entire page. (But why would you want to do that).

The most likely use would be


where myHelpfile is a CfD field with something like:


then you would have a nice explanation why this wasn't good and what can be done about it.

:-) stw