I have a script written in JavaScript to Validate Canadian Postal Codes using Regex, however it does not seem to be working. Here is the script:
If statement:
         
        Solution for you answer, it will help i hope. Thanks for your time
string[] inputName = new string[5];
    string[] inputId = new string[5];
    string[] inputMarks = new string[5];
    Regex StudentId = new Regex(@"\d\d\d\d\d$");
    Regex Marks = new Regex(@"\d\d$");
    Regex StudentName = new Regex(@"^([a-zA-z\s]{5,10})$");
    private void btnClear_Click(object sender, EventArgs e)
    {
        rtShowAll.Clear();
    }
    private void btnAdd_Click(object sender, EventArgs e)
    {
        string Name = txtLastName.Text;
        string id = txtStudentId.Text;
        string marks = txtMarks.Text;
        if ((Name == "") || (!StudentName.IsMatch(Name)))
        {
            MessageBox.Show("space cannot be empty and enter valid characters only");
        }
        else if (Name != "")
        {
            if ((id == null) || (StudentId.IsMatch(id)))
            {
                MessageBox.Show("Enter valid id");
            }
            else if ((id != null) || (StudentId.IsMatch(id)))
            {
                if ((marks == null) || (!Marks.IsMatch(marks)))
                {
                    MessageBox.Show("enter valid marks");
                }
                else if ((marks != null) || (Marks.IsMatch(marks)))
                {
                    for (int i = 0; i <= 5; i++)
                    {
                        inputName[i] = Name;
                        inputId[i] = id;
                        inputMarks[i] = marks;
                        break;
                    }
                }
            }
        }
        txtLastName.Clear();
        txtMarks.Clear();
        txtStudentId.Clear();
    }
    private void btnShowAll_Click(object sender, EventArgs e)
    {
        string result = "";
        for (int i = 0; i <= 5; i++)
        {
            result = inputName[i] + "   " + inputId[i] + "   " + inputMarks[i];
            rtShowAll.Text = result;
            break;
        }
       //list.Add(rtShowAll.Text);
        //string Showall = "";
       // foreach (string s in list)
      // {
       //    Showall += s + " "+ "\n";
        //}
       // rtShowAll.Text = Showall;
    }
    private void btnSearch_Click(object sender, EventArgs e)
    {
        string searchId = txtStudentId.Text;
        string result = "";
        txtStudentId.Text = searchId;
        for (int i = 0; i < 5; i++)
        {
            if (searchId == inputId[i])
            {
                result = inputName[i] + "    " + inputMarks[i];
                rtSearch.Text = result;
            }
            else if (searchId != inputId[i])
            {
                MessageBox.Show("Enter valid Student id");
            }
        }
    }
    private void btnModify_Click(object sender, EventArgs e)
    {
        string id = txtStudentId.Text;
        string newmarks = "";
        for (int i = 0; i < 5; i++)
        {
            if (id == inputId[i])
            {
                newmarks = txtMarks.Text;
                if ((newmarks == null) || (!Marks.IsMatch(newmarks)))
                {
                    MessageBox.Show("enter valid marks");
                }
                else if ((newmarks != null || (Marks.IsMatch(newmarks))))
                {
                    inputMarks[i] = newmarks;
                    MessageBox.Show("marks has been modified");
                }
            }
        }
    }
}
}