Form Validation: Check if nonrequired fields are selected

Hello all,

I'm seeking for some validation help. I've tried a couple of ways to
accomplished this but not getting what I want. I'm using interceptAction
to intercept the submit button to call a function before the button is
executed to check. I'd like to check if any fields A thru E are selected
if not then at least one selection is required before processing. 

This sounds like an easy statement but I'm having a hard time getting
it to work. I'm new to ECMAScript and just now starting to get familiar
with some functionality. 
-------------------------
Name: Require 
Last Name: Require
Reason: Require

SystemA: NonRequire
SystemB: NonRequire
SystemC: NonRequire
SystemD: NonRequire
SystemE: NonRequire

Comment: NonRequire

Submit  Cancel

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

Not sure if this is the best approach. I'm using an onload event on
SystemA field.  

var selection = form.getValue("SystemA")
var selection1 = form.getValue("SystemB")

form.interceptAction("SubmitAction", "before", 
function (invocation){
if(selection == null && selection1 == null)
{
form.setRequired("?????", true) Not sure how to tell it to set at least
one field required.
}
else
{form.getValue()}
});


Any help will  be appreciated. 

Thank you!


-- 
ee0001
------------------------------------------------------------------------



0
ee0001
4/5/2011 1:06:02 PM
novell.id-manager.userapp 4379 articles. 0 followers. Follow

9 Replies
443 Views

Similar Articles

[PageSpeed] 21

Easiest option may be that you can show a alert box like

if(selection == null && selection1 == null)
{
//form.setRequired("?????", true) Not sure how to tell it to set at
least one field required.

alert('Please provide value for one field..... blah blah ');
}


-- 
gupta1vipin
------------------------------------------------------------------------
gupta1vipin's Profile: http://forums.novell.com/member.php?userid=86078
View this thread: http://forums.novell.com/showthread.php?t=436262

0
gupta1vipin
4/5/2011 1:36:04 PM
gupta1vipin;2093036 Wrote: 
> Easiest option may be that you can show a alert box like
> 
> if(selection == null && selection1 == null)
> {
> //form.setRequired("?????", true) Not sure how to tell it to set at
> least one field required.
> 
> alert('Please provide value for one field..... blah blah ');
> }


Thanks for your reply but that was actually my first attempt but didn't
work as expected. The alert message shows everytime the submit button is
clicked even if the validation is valid and one of the required fields
is not populated.  So to avoid the alert message to display every time I
used form.showError("Please provide value for one field..... blah
blah"); but this displays the error message and submits the requests
without a selection required.  So I'm assuming I need to set any field
to be required when validation is valid to require a selection before
submission.

Any suggestions?


-- 
ee0001
------------------------------------------------------------------------
ee0001's Profile: http://forums.novell.com/member.php?userid=85394
View this thread: http://forums.novell.com/showthread.php?t=436262

0
ee0001
4/5/2011 3:06:03 PM
Check the Cool Solutions article that I have published about two weeks ago. 
It covers exactly these issues:
http://www.novell.com/communities/node/12645/howto-validata-form-input-and-disable-submit-user-application-forms

Wolfgang


"ee0001"  wrote in message news:ee0001.4rq2s0@no-mx.forums.novell.com...


Hello all,

I'm seeking for some validation help. I've tried a couple of ways to
accomplished this but not getting what I want. I'm using interceptAction
to intercept the submit button to call a function before the button is
executed to check. I'd like to check if any fields A thru E are selected
if not then at least one selection is required before processing. 

0
Wolfgang
4/5/2011 3:53:31 PM
On Tue, 05 Apr 2011 13:06:02 +0000, ee0001 wrote:

> I'm seeking for some validation help. I've tried a couple of ways to
> accomplished this but not getting what I want. I'm using interceptAction
> to intercept the submit button to call a function before the button is
> executed to check. I'd like to check if any fields A thru E are selected
> if not then at least one selection is required before processing.

If I'm understanding what you're trying to do, you might set this up as a 
MVCheckbox list, with Required turned on. If you want one-and-only-one of 
the list selected, that's a bit more work, but can also be done.


-- 
---------------------------------------------------------------------------
 David Gersic                                            dgersic_@_niu.edu
 Novell Knowledge Partner                         http://forums.novell.com

 Please post questions in the newsgroups.   No support provided via email.

0
David
4/5/2011 5:30:03 PM
I understand the concept of having a MVCheckbox list and setting it to 
require, but most of  SystemA - SystemE fields are picklists with a 
selection menus, some are MVCheckboxs and other are Global lists. So
that will not work in my case. I would love to find a way to validate 
that at least one field is selected to proceed with the request.

If I can only get an idea on how to accomplished it would be great.


-- 
ee0001
------------------------------------------------------------------------
ee0001's Profile: http://forums.novell.com/member.php?userid=85394
View this thread: http://forums.novell.com/showthread.php?t=436262

0
ee0001
4/5/2011 6:06:05 PM
What about something like this:


form.interceptAction( ACTION_SUBMIT, "around",
   function ( invocation )
   {
      var selectionA = form.getValue("SystemA");
      var selectionB = form.getValue("SystemB");
      var selectionC = form.getValue("SystemC");
      var selectionD = form.getValue("SystemD");

      var result = ( selectionA != "" )
                && ( selectionB != "" )
                && ( selectionC != "" )
                && ( selectionD != "" );
      if ( result )
      {
         result = invocation.proceed();
      }
      else
      {
         alert( "Just what do you think you're doing, Dave?" );
      }
      return result;
   }
);



Wolfgang



"Wolfgang Schreiber"  wrote in message 
news:%VGmp.27257$325.18786@kovat.provo.novell.com...

Check the Cool Solutions article that I have published about two weeks ago.
It covers exactly these issues:
http://www.novell.com/communities/node/12645/howto-validata-form-input-and-disable-submit-user-application-forms

Wolfgang


"ee0001"  wrote in message news:ee0001.4rq2s0@no-mx.forums.novell.com...


Hello all,

I'm seeking for some validation help. I've tried a couple of ways to
accomplished this but not getting what I want. I'm using interceptAction
to intercept the submit button to call a function before the button is
executed to check. I'd like to check if any fields A thru E are selected
if not then at least one selection is required before processing. 

0
Wolfgang
4/5/2011 7:15:10 PM
ee0001;2093080 Wrote: 
> Thanks for your reply but that was actually my first attempt but didn't
> work as expected. The alert message shows everytime the submit button is
> clicked even if the validation is valid and one of the required fields
> is not populated.  So to avoid the alert message to display every time I
> used form.showError("Please provide value for one field..... blah
> blah"); but this displays the error message and submits the requests
> without a selection required.  So I'm assuming I need to set any field
> to be required when validation is valid to require a selection before
> submission.
> 
> Any suggestions?

Sounds interesting... 

I have implemented same kinda requirement using this. Not sure why not
working for you.
Okay... Try one thing. Before applying your validation, just alert the
values from all of the selection field. There might be a possibility
that default values are not null or might be blank. Just check it once.


-- 
gupta1vipin
------------------------------------------------------------------------
gupta1vipin's Profile: http://forums.novell.com/member.php?userid=86078
View this thread: http://forums.novell.com/showthread.php?t=436262

0
gupta1vipin
4/6/2011 5:06:01 AM
Wolfgang Schreiber;2093282 Wrote: 
> What about something like this:
> 
> 
> form.interceptAction( ACTION_SUBMIT, "around",
> function ( invocation )
> {
> var selectionA = form.getValue("SystemA");
> var selectionB = form.getValue("SystemB");
> var selectionC = form.getValue("SystemC");
> var selectionD = form.getValue("SystemD");
> 
> var result = ( selectionA != "" )
> && ( selectionB != "" )
> && ( selectionC != "" )
> && ( selectionD != "" );
> if ( result )
> {
> result = invocation.proceed();
> }
> else
> {
> alert( "Just what do you think you're doing, Dave?" );
> }
> return result;
> }
> );
> 
> 
> 
> Wolfgang
> 
> 
> 
> "Wolfgang Schreiber"  wrote in message
> news:%VGmp.27257$325.18786@kovat.provo.novell.com...
> 
> Check the Cool Solutions article that I have published about two weeks
> ago.
> It covers exactly these issues:
> 'HowTo: Validate Form Input and Disable Submit in User Application
> Forms | Novell User Communities'
> (http://www.novell.com/communities/node/12645/howto-validata-form-input-and-disable-submit-user-application-forms)
> 
> Wolfgang
> 
> 
> "ee0001"  wrote in message
> news:ee0001.4rq2s0@no-mx.forums.novell.com...
> 
> 
> Hello all,
> 
> I'm seeking for some validation help. I've tried a couple of ways to
> accomplished this but not getting what I want. I'm using
> interceptAction
> to intercept the submit button to call a function before the button is
> executed to check. I'd like to check if any fields A thru E are
> selected
> if not then at least one selection is required before processing.


Your Cool Solution article is neat and may be able to use it for other
forms with text fields only. This particular form contains dynamically
generated picklists and MV Checkbox (based on another great cool
solution article 'here'
(http://www.novell.com/communities/node/9601/user-application-approval-forms-dynamically-generated-mv-checkboxpicklists-or-text-picklis))
When applying the on-the-fly validation script it throws errors while
executing the gobal queries. When the script is removed/or commented
then the fields are generated just fine. I wonder if by using
dynamically genered fields and queires is making this too complex. 

so I tried adding the suggested script above to find when the submit
button is clicked the alert message displays and when the OK button is
clicked the forms submits without user section required.  

So I think if I can get the submit button to be disable after the alert
displays and when is function is valid then enable submit. This may do
what I want. Something like this:

form.interceptAction( ACTION_SUBMIT, "before",
function ( invocation )
{
var selectionA = form.getValue("TranCollector");
var selectionB = form.getValue("TranCollectorPrinter");
var selectionC = form.getValue("TranCollector2");
var selectionD = form.getValue("test");

var result = ( selectionA != '' )
&& ( selectionB != '' )
&& ( selectionC != '' )
&& ( selectionD != '' );
{
if ( result ) 
{
result = invocation.proceed();
************************ENABLE SUBMIT
}
else
{
form.alert("A system must be selected before proceeding")
************************ DISABLE SUBMIT
}
return result;
}
}
);

Is this possible?


-- 
ee0001
------------------------------------------------------------------------
ee0001's Profile: http://forums.novell.com/member.php?userid=85394
View this thread: http://forums.novell.com/showthread.php?t=436262

0
ee0001
4/6/2011 3:36:04 PM
A simple validation I have done is to have a hidden field that is
required and then on the optional fields write something in the hidden
field in an "on change" event.


-- 
-----------------------------------
joakim . ganse_@_ accept-it . se
------------------------------------------------------------------------
joakim_ganse's Profile: http://forums.novell.com/member.php?userid=6236
View this thread: http://forums.novell.com/showthread.php?t=436262

0
joakim
4/7/2011 7:06:02 AM
Reply: