Hi @RAVI,
If you only need to verify the three numbers 11, 22, and 33, it is very easy to do.
protected void Button1_Click(object sender, EventArgs e)
{
string a = TextBox1.Text;
if(a != "11" && a!="22" && a != "33")
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Wrong Data');", true);
TextBox1.Text = "";
}
}
If you want to verify the multiple of 11, as follows:
protected void Button1_Click(object sender, EventArgs e)
{
string a = TextBox1.Text;
if (int.TryParse(a, out int value))
{
bool isMultiple = value % 11 == 0;
if (isMultiple == false)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Wrong Data');", true);
TextBox1.Text = "";
}
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Wrong Data');", true);
TextBox1.Text = "";
}
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread