C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




regular Expression


Posted Date: 25 Jul 2008      Total Responses: 3

Posted By: Sanjana       Member Level: Silver     Points: 1



Hello,

Can someone help me with regular expression. I would like to accept following inputs for phone number field:

748-451-1425 or

451-1425 or

8-1425

Thanks,





Responses

Author: mani kumar.k.m    25 Jul 2008Member Level: GoldRating:     Points: 6

Hi Sanjana,

pls try this,

<script>
function fun1()
{
var Phone1;
Phone1 = /^\+?\s*\d{12}|\s*\d{3}\s\*[\-]?\s*\d{8}|[0-9]+$/;



var phone1 = document.getElementById('txtCellNo').value;


if (phone1.search(Phone1) == -1 && phone1 != "")
{
alert ("Please Enter the CellNo in correct format (555) 555-5555 Or 555.555.5555 Or 555 555-5555");
document.form1.txtCellNo.focus();
return false;
}
else
{
return true;
}
}

</script>

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
btnSave.Attributes.Add("onClick", "return fun()");
}


it may be help you,

Thanks & Regards




Author: suman    25 Jul 2008Member Level: GoldRating:     Points: 1

748-451-1425 \d{3}\-\d{3}\-\d{4}

451-1425 \d{3}\-\d{4}

8-1425 \d{1}\-\d{4}



Author: Lakshmankumar M    25 Jul 2008Member Level: GoldRating:     Points: 6

<script>
function fun1()
{
var Phone1;
Phone1 = /^\+?\s*\d{12}|\s*\d{3}\s\*[\-]?\s*\d{8}|[0-9]+$/;



var phone1 = document.getElementById('txtCellNo').value;


if (phone1.search(Phone1) == -1 && phone1 != "")
{
alert ("Please Enter the CellNo in correct format (555) 555-5555 Or 555.555.5555 Or 555 555-5555");
document.form1.txtCellNo.focus();
return false;
}
else
{
return true;
}
}

</script>

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
btnSave.Attributes.Add("onClick", "return fun()");
}


it may be help you,



Post Reply
You must Sign In to post a response.
Next : urgent..sending Mail with image...
Previous : decreace length
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use