This topic is locked
[SOLVED]

  Add regular expression validation to the control?

6/5/2012 7:51:49 PM
PHPRunner General questions
J
joiresende author

I have an application that uses:
var ctrl = Runner.getControl(pageid, 'Number');

ctrl.addValidation({

regex: "[0-9]",

message: "The field should be a number from 0 to 9",

messagetype: "Text"

});
would like to use?
regex: > 100

Admin 6/5/2012

Regular expressions are not suited for such a task. Use custom validation routine instead.
More info:

http://xlinesoft.com/phprunner/docs/validation_types.htm#own_validation_type

J
joiresende author 6/6/2012

Thanks for the reply.

I tried to find the solution and not found. What I need to be validated when the field is greater than 100 (> 100).

Does anyone have an example?

Admin 6/7/2012

You need to use a custom validation plugin. In that plugin you can use any Javascript code. Checking if certain value if less or more than 100 is trivial in Javascript:

if (someVal>100)

{

// do something

}
J
joiresende author 6/7/2012

Please you have any examples for inspiration?

C
cgphp 6/7/2012
  1. Create a file called greater.js
  2. Add the following function to this file:

function greater(sVal)

{

if(sVal > 100)

return true;

else

return 'This value should be greater than 100';

}


3. Store file greater.js to the <PHPRunner install folder>\source\include\validate folder (for example: C:\Program Files\PHPRunner6.1\source\include\validate)
4. Start PHPRunner. Now greater validation type is available in the list of validation types and you can use it in your projects.

J
joiresende author 6/7/2012

thanks, worked perfectly