Validation ----> Lock the text box without enabling to enter a single letter or a digit or a space or anything.
I just want to know that how do you do hard coding for validation of a text box. If it's a method or seperate function that would be easy for me. Then, it's easy for me to reuse that coding in the key press event of each text box.
Dinusha GamagePosted May 26, 2008, 2:39 AM
Dear Friend,
Thank you very much for your reply. But I need a small clarification about this coding. That is I jz want to know whether Javascript coding can be used in C # coding. Here, I'm developing a windows application, so... Can you apply these coding to validate text boxes in widows form?
Thanks in advance !
Niradhip ChakrabortyPosted May 23, 2008, 2:02 PM
You should call a javascript function in onclick or onkeypress event.
I will give you javascript function for the validation.
//To check whether a adress is proper email address or not.
function isEmail(s){
if (s.search(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/) == -1){
return false;
}
else{
return true;
}
}
//To check input is dizit or Character. This function will only allow user to enter number
function ValidatePhoneNo(Obj){
if(((window.event.keyCode >= 48) && (window.event.keyCode <= 57))){
var Value = Obj.value;
var len = Value.length;
if (len == 3 || len == 7 ){
Obj.value = Value + '-';
return true;
}
}
else{
alert("Phone No Cannot be a Character");
return false;
}
}
//the following function will disable a textbox call it in onload.My textbox id is txtVendorName
Function disable()
{
document.getElementById("txtVendorName").disable = true;
}
Dinusha GamagePosted May 22, 2008, 11:05 PM
Yes. At client side.
Niradhip ChakrabortyPosted May 22, 2008, 12:44 PM