Skip to main content

I have three fields: BusUnit, SLType and SLNo


I need to write code or rule that will check the first character of "BusUnit" and if it is a Letter then it makes the "SLType" and "SLNo" fields mandatory.


 


Is this possible?

Hi. Add this rule to SLType and SLNo

not(isNumeric(subString(BusUnit,0,1))) && isNullOrEmpty({Self})

What it does: The subString function grabs the fist letter of what is in the control BusUnit. Then checks if its a number using the isNumeric function. If its not a number then its a letter so returns false but the NOT then reverses that to make it true.
then if SLType is also empty it makes the whole rule true which invalidates the control.
Add the same rule to SLNo.

Thank you Simon Muntz!


What if the first character is not a number or a letter (shouldn't be) ?  I am thinking it was then make the 2 field mandatory even though it is not a letter.  I don't want them to be able to type any special characters either.  Just A-Z or a-z or 0-9,  That should be a RegEx expression validation for field as well, correct?


I added the rules but they don't seem to be working.  I have attached my form.


{Self} is a token that you will find in the named controls. You have just typed it in.
Use Self or the actual name of the control.

Reply