This topic is locked
[SOLVED]

 Validation on 3 Text fields (Advanced)

11/2/2012 4:43:45 AM
PHPRunner General questions
I
Ivan van Oosterhout author

Hello again,
I want to validate 3 textfields, and minimum 1 has to be filled in with a number.


Is there a Java script or something to validate this? or other validation with a message?
When you dont fill in one of the 3 textfields it has to give a message saying something like: Please fill one of these fields..
kind regards,

C
cgphp 11/2/2012
var ctrlPAL = Runner.getControl(pageid,'PAL');

var ctrlCTN = Runner.getControl(pageid,'CTN');

var ctrlGOH = Runner.getControl(pageid,'GOH');
ctrlPAL.addValidation('IsRequired');
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){

if(ctrlPAL.getValue() == '' && ctrlCTN.getValue() == '' && ctrlGOH.getValue() == '')

{

ctrlPAL.validate();

}

else

{

ctrlPAL.removeValidation('IsRequired');

}

});
I
Ivan van Oosterhout author 11/2/2012

Hello Christian,
Thank you its working but...
If people forget to place the ammount and press save, the message comes saying "This field is Required" Very nice!!!
But the Savebutton is pressed down and if you fill in the correct ammount and press save its not possible.
So i guess:
When you press save without fill the ammount the Save button has to refresh or something like that.
Is that possible?

C
cgphp 11/2/2012

It works fine for me. What PHPrunner version/build are you using?

I
Ivan van Oosterhout author 11/2/2012

Hi Christian,
I have PHP Runner Enterprise6.2 (build 13442)
Let me show you,


Kind regards,

C
cgphp 11/2/2012

I'm using the build 13703.

I
Ivan van Oosterhout author 11/2/2012

Thank you,
Need to download that one, will ask Sergey for the Link..
Kinds Regards,

I
Ivan van Oosterhout author 11/2/2012

Problem Solved Christian,
Thanks Very Much

I
Ivan van Oosterhout author 11/15/2012

Hi Christian,
In this code PAL must be filled in at all times, but can i set it that it doesnt matter which field you fill in aslong as you fill minimal 1 field and it cannot be 0...
var ctrlPAL = Runner.getControl(pageid,'PAL');

var ctrlCTN = Runner.getControl(pageid,'CTN');

var ctrlGOH = Runner.getControl(pageid,'GOH');
ctrlPAL.addValidation('IsRequired');
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){

if(ctrlPAL.getValue() == '' && ctrlCTN.getValue() == '' && ctrlGOH.getValue() == '')

{

ctrlPAL.validate();

}

else

{

ctrlPAL.removeValidation('IsRequired');

}

});