| Author: Vidhya 01 Aug 2008 | Member Level: Gold | Rating: 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 2008 | Member Level: Gold | Rating: 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 2008 | Member Level: Gold | Rating: 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 2008 | Member Level: Gold | Rating: 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.
|