This topic is locked
[SOLVED]

 validate one field depending on another fields value

3/11/2015 5:35:20 AM
PHPRunner General questions
A
Abbas author

Hi,
I want to make validate one field depending on another fields value.
I have 3 text fields:
field_A

field_B

field_C
I want to validate field_C by this condition:
if field_A & field_B is not empty then

field_C is required
else
field_C is not required
I've written this code into OnLoad event but it is not work fine

var fieldA = Runner.getControl(pageid, 'field_A');

var fieldB = Runner.getControl(pageid, 'field_B');

var fieldC = Runner.getControl(pageid, 'field_C');
fieldA.on('change', function(e) {

if (this.getValue() && fieldB.getValue()) {

fieldC.addValidation("IsRequired");

} else {

fieldC.removeValidation("IsRequired");

}

});


I appreciate your time and help on this.
Regards,

Abbas

A
Abbas author 3/13/2015
A
Anapolis 3/15/2015



It is not SOLVED <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=76987&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' />



you might try something like this:

var ctrlFieldA = Runner.getControl(pageid, 'field_A');

var ctrlFieldB = Runner.getControl(pageid, 'field_B');

var ctrlFieldC = Runner.getControl(pageid, 'field_C');
ctrlFieldA.on('change', function(e) {

if (this.getValue() != '' && ctrlFieldB.getValue() != '')

{ctrlFieldC.addValidation('IsRequired');

}

else

{

ctrlFieldC.removeValidation('IsRequired');

}

});