How to validate user input for mobile number using Regular Expression in Javascript

InfoPath alternatives for form designing SharePoint

The below Html code explains the client side validation for mobile number using Regular Expressions.

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>

<html xmlns=””>

<head runat=”server”>

<title>Untitled Page</title>

<script language=”ecmascript” type=”text/ecmascript”>

function validateMobileNo() {

var p1 = /^([0-9]{10})$/;

var mobile_no = form1.Text1.value;

var x1 = mobile_no.match(p1);

if (x1 == null) {

alert(“Invalid User Input”);

return false;


return true;




<form id=”form1″ runat=”server”>


Enter Mobile Number:

<input id=”Text1″ name=”txt1″ type=”text” /><br />

<br />

<asp:Button ID=”Button2″ OnClientClick =”return validateMobileNo();” Text=”MobileNoCheck” runat=”server” />





Similar SharePoint 2013 Tutorials

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →

Leave a Reply