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 !




I need code to validate email,phone number,string


Posted Date: 01 Aug 2008      Total Responses: 4

Posted By: Rajashekar       Member Level: Silver     Points: 1



Hi, Can any one send me the javascript code to validate
email ,Phone number, name (or) string...Thank you in advance.

Regards,
shekar.





Responses

Author: Vidhya    01 Aug 2008Member Level: GoldRating:     Points: 6

protected void Page_Load(object sender, EventArgs e)
{
labelResponse.Text = "";
}
protected void buttonSubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
labelResponse.Text = "Your request has been processed. Thank you.";
}
else
{
labelResponse.Text = "Date is not valid.";
}
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
try
{
DateTime.ParseExact(args.Value, "d", null);
args.IsValid = true;
}
catch
{
args.IsValid = false;
}
} protected void checkPhoneConfirmation_CheckedChanged(object sender, EventArgs e)
{
if(checkPhoneConfirmation.Checked)
{
textPhoneNumber.Enabled = true;
validatorRequiredPhoneNumber.ValidationGroup = "AllValidators";
validatorRegExPhoneNumber.ValidationGroup = "AllValidators";
}
else
{
textPhoneNumber.Enabled = false;
validatorRequiredPhoneNumber.ValidationGroup = "";
validatorRegExPhoneNumber.ValidationGroup = "";
}
}



Author: Koteswara Rao    01 Aug 2008Member Level: GoldRating:     Points: 3

Email:
http://www.smartwebby.com/DHTML/email_validation.asp
Phone :
http://www.smartwebby.com/DHTML/phone_no_validation.asp
Name:
http://www.configure-all.com/javascript_form_validation.php



Author: Sree Raj    01 Aug 2008Member Level: GoldRating:     Points: 6

hi

Email validation code

function validate(form_id,email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = document.forms[form_id].elements[email].value;
if(reg.test(address) == false) {
alert('Invalid Email Address');
return false;
}




Phone Number Validation



<script type="text/javascript">
function FormValidate()
{
if(document.Form1.PhoneNumber.value.search(/\d{3}\-\d{3}\-\d{4}/)==-1)
{
alert("The phone number you entered is not valid.\r\nPlease enter a phone number with the format xxx-xxx-xxxx.");
return false;
}
}
</script>


For NAme Validation

Use this rebExp "^[A-Z]+[a-zA-Z]*$" . same like email and phone validation


Regards
SreeRaj


}





Author: NP Senthil kumar    01 Aug 2008Member Level: GoldRating:     Points: 3

Hi,
try using compare validator for checking the datatype like date, string , integer.

Use regular expression validator to check for the email, phone number , zipcode.



Post Reply
You must Sign In to post a response.
Next : window.close() in javascript
Previous : javascript replace
Return to Discussion Forum
Post New Message
Category: JavaScript

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use