This topic is locked

Conditional required field

7/27/2016 10:35:05 AM
PHPRunner General questions
P
PHPRunnerExplorer author

Hi,
Is there a way to conditionally set the required attribute, on a field? I can do it with php and html, no problem. But cannot figure out how to set this up, in PHPRunner.
The specific field is a Social Security Number. This is required as a default, in our application. But if one Checkbox field is checked, then the Social Security number is not required.

jadachDevClub member 7/27/2016

I am asking a very similar question on the ASPR.Net Forum

http://www.asprunner.com/forums/topic/24027-javascript-help/

P
PHPRunnerExplorer author 7/27/2016

Thanks, Jadach and Romaldus.

romaldus 7/27/2016



Thanks, Jadach and Romaldus.


Sample Code.

Tested on phprunner 8 and 9


var F1 = Runner.getControl(pageid, 'field1');

var F2 = Runner.getControl(pageid, 'field2');
F1.on('change', function(e)

{

if (this.getValue() == 'YES')

{

F2.addValidation('IsRequired');

}

else

{

F2.removeValidation('IsRequired')

}

});