How to validate multiple fields within a form?

How to validate multiple fields within a form?

I have a form that has the fields "Name" "Email" "Mobile Number" and "Office Number". I wanted to validate that when they entered a Mobile Number they were entering 10 digits with no dashes so I coded this:
Mobile_NumberFormat = input.Mobile_Number.toString().replaceAll("([0-9]{10})","correct");
if (Mobile_NumberFormat  !=  "correct")
{
    alert "Mobile Number Should Be 10 Digits, No Dashes";
    cancel submit;
}
I want to do the same thing with the "Office Number", but I don't know how to say if the Office Number is not correct then displace "Office Number Should Be 10 Digits, No Dashes"