Asp.net 2.0 + c#
-
In my application i have two textboxes and a save button. ON clicking Save button on client side i want to check that the textboxes are not empty and display the appropriate message on the label controls. thanks in advance.
Use RequiredFieldValidator. Add a RequiredFieldValidator and set the property ControlTovalidate as your textboxname , set the appropriate error message on ErrorMessage property
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
Use RequiredFieldValidator. Add a RequiredFieldValidator and set the property ControlTovalidate as your textboxname , set the appropriate error message on ErrorMessage property
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
no i cannot use requiredfieldvalidator . I want to have clint side interaction;requiredfieldvalidator works on server side .Something in javascripting ?????????
No buddy. It works in client side. Anyway the javascript code for mandatory text field is here function RequiredField() { document.getElementById("lblErrormessage").innerText = ''; if(document.getElementById("TextBox1").value == '') { document.getElementById("lblErrormessage").innerText = "Field is required"; return false; } return true; } add this method in Page_Load event code bahind on some submit button onclick like button1.Attributes.Add("onclick","return RequiredField()");
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
No buddy. It works in client side. Anyway the javascript code for mandatory text field is here function RequiredField() { document.getElementById("lblErrormessage").innerText = ''; if(document.getElementById("TextBox1").value == '') { document.getElementById("lblErrormessage").innerText = "Field is required"; return false; } return true; } add this method in Page_Load event code bahind on some submit button onclick like button1.Attributes.Add("onclick","return RequiredField()");
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
Of course, "Textbox1" won't work, as the framework assigns it's own Id, based on where the control is in the page heirarchy. You're definately better off using the validators, which do indeed work on the client.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
No buddy. It works in client side. Anyway the javascript code for mandatory text field is here function RequiredField() { document.getElementById("lblErrormessage").innerText = ''; if(document.getElementById("TextBox1").value == '') { document.getElementById("lblErrormessage").innerText = "Field is required"; return false; } return true; } add this method in Page_Load event code bahind on some submit button onclick like button1.Attributes.Add("onclick","return RequiredField()");
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
no i have a problem here . i have two textboxes .The problem is with this . At a time only one label gives text the other is not. i cant understand this . function checknews() { var reqheadline,reqnewsdetail; reqheadline=document.getElementById("TextBox1").innerText; reqnewsdetail=document.getElementById("TextBox2").innerText ; alert(reqnewsdetail); if(reqheadline=="") { document.getElementById("label5").innerText = "Enter Headline" ; return false; } if(reqnewsdetail=="") { alert("bhavna"); document.getElementById("label6").innerText = "Enter News Details" ; return false ; } return true; }
-
no i have a problem here . i have two textboxes .The problem is with this . At a time only one label gives text the other is not. i cant understand this . function checknews() { var reqheadline,reqnewsdetail; reqheadline=document.getElementById("TextBox1").innerText; reqnewsdetail=document.getElementById("TextBox2").innerText ; alert(reqnewsdetail); if(reqheadline=="") { document.getElementById("label5").innerText = "Enter Headline" ; return false; } if(reqnewsdetail=="") { alert("bhavna"); document.getElementById("label6").innerText = "Enter News Details" ; return false ; } return true; }
change like this. if it works give score for me if(reqheadline=="") document.getElementById("label5").innerText = "Enter Headline" ; if(reqnewsdetail=="") document.getElementById("label6").innerText = "Enter News Details" ; if(reqheadline=="" || reqnewsdetail=="") return false ;
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
change like this. if it works give score for me if(reqheadline=="") document.getElementById("label5").innerText = "Enter Headline" ; if(reqnewsdetail=="") document.getElementById("label6").innerText = "Enter News Details" ; if(reqheadline=="" || reqnewsdetail=="") return false ;
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
add return true; in the end. Why are you not thinking simple logiv I dont know Anyway all the best
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
add return true; in the end. Why are you not thinking simple logiv I dont know Anyway all the best
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
not working var reqheadline,reqnewsdetail; reqheadline=document.getElementById("TextBox1").innerText; reqnewsdetail=document.getElementById("TextBox2").innerText ; if(reqheadline=="") document.getElementById("label5").innerText = "Enter Headline" ; if(reqnewsdetail=="") document.getElementById("label6").innerText = "Enter News Details" ; if(reqheadline=="" || reqnewsdetail=="") return false ; return true; }
-
not working var reqheadline,reqnewsdetail; reqheadline=document.getElementById("TextBox1").innerText; reqnewsdetail=document.getElementById("TextBox2").innerText ; if(reqheadline=="") document.getElementById("label5").innerText = "Enter Headline" ; if(reqnewsdetail=="") document.getElementById("label6").innerText = "Enter News Details" ; if(reqheadline=="" || reqnewsdetail=="") return false ; return true; }
what is the error you are getting?
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
what is the error you are getting?
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
why are you changing your code yourself. see my code for text box as if(document.getElementById("TextBox1").value == '') but you changed as innerText. for textbox its value for label its innerText ok
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
why are you changing your code yourself. see my code for text box as if(document.getElementById("TextBox1").value == '') but you changed as innerText. for textbox its value for label its innerText ok
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
You have to sharpen your Javascript knowledge. Read this link which is from w3cschools.this will help you alot http://www.w3schools.com/js/default.asp[^]
Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com
-
In my application i have two textboxes and a save button. ON clicking Save button on client side i want to check that the textboxes are not empty and display the appropriate message on the label controls. thanks in advance.