Hi Hafifiw,
Please refer below sample.
HTML
<asp:TextBox runat="server" ID="txtNumber" />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="OnSubmit" />
Code
C#
protected void OnSubmit(object sender, EventArgs e)
{
string number = txtNumber.Text;
for (int i = 0; i < number.Split(',').Length; i++)
{
bool isNumber = IsNumeric(number.Split(',')[i]);
if (!isNumber)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + number.Split(',')[i] + " is not a number.');", true);
break;
}
}
}
public bool IsNumeric(string value)
{
return value.All(char.IsNumber);
}
VB.Net
Protected Sub OnSubmit(ByVal sender As Object, ByVal e As EventArgs)
Dim number As String = txtNumber.Text
For i As Integer = 0 To number.Split(","c).Length - 1
Dim isNumber As Boolean = IsNumeric(number.Split(","c)(i))
If Not isNumber Then
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('" & number.Split(","c)(i) & " is not a number.');", True)
Exit For
End If
Next
End Sub
Public Function IsNumeric(ByVal value As String) As Boolean
Return value.All(AddressOf Char.IsNumber)
End Function
Screenshot