Hi. I have a doubt in nested if's
here, if the first condition is true, then it will be return the statement "should be 18 digits". If it's false, I want null value to be returned. Since I am using nested if's its returning "must be numerical and no more than 12no's". how can we resolve this. Can someone help me here?
Discussion posts and replies are publicly visible
It would help if you can describe what you are trying to accomplish (e.g., when should "..no more than 12 numbers" show?), and expand your and() statements.
Currently, your empty array (not null technically) would be returned in the situation where the first if() evaluates false and the second if() evaluates to true.
hema.mathivathanan said:The problem with the above coding is, the second if is working as expected. But when the first if statement returns false
This is not possible. As I explained earlier, the second if() only ever executes when the top-level if() evaluates to FALSE.
I suggest you review and get more familiar with the precedence in which nested if() statements execute. Namely, that they execute stricly in order from the top-most level, and any nested expressions will only ever be evaluated when the parent condition evaluates in such a way as to call that particular child path (i.e. either the "true" path or the "false" path).