Write a code for "RequiredFieldValidator" in java script
Answers were Sorted based on User's Feedback
Answer / rajikiran
function validate()
{
if(document.getElementById("NameId").value == null)
alert("Please enter the name");
document.getElementById("NameId").focus();
return false;
}
or
function validate()
{
with(document.formname)
{
txtboxid.value == ""
alert("Please enter value");
txtboxid.focus();
return false;
}
}
or we can use
document.form.txtboxid.value
instead of
document.getElementById("NameId").value
regards
rajikiran
Is This Answer Correct ? | 7 Yes | 3 No |
Answer / manoj
suppose the id of the field required to be validated is
NameId
Thus:-
function validate()
{
if(document.getElementById("NameId").value == null)
alert("Please enter the name");
}
Is This Answer Correct ? | 5 Yes | 3 No |
Answer / amit patel
function validate()
{
if(document.getElementById('<%=Name.ClientID%>').value
== "")
alert("Please enter the name");
document.getElementById("Name").focus();
return false;
}
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / jayamala
function validate()
{
if(document.getElementById("NameId").value =="")
alert("Please enter the name");
document.getElementById("NameId").focus();
return false;
}
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / sudhakar sakthivel
function validate()
{
if(document.getElementById("NameId").value == null ||
document.getElementById("NameId").value.trim()=="")
alert("Please enter the name");
document.getElementById("NameId").focus();
return false;
}
Is This Answer Correct ? | 0 Yes | 1 No |
What is the purpose of the following segment? If ( !IsPostBack) { sqldataAdapter1.Fill (dsusers1); DataGrid1.DataBind (); } a) To populate the DataAdapter the first time the web page id displayed. b) To populate the DataSet every time the web page is displayed. c) To populate the DataAdapter every time the web page is displayed. d)To populate the DataSet the first time the web page is displayed.
What are the various authentication mechanisms in ASP.NET ?
1 Answers Digital GlobalSoft, Satyam,
You ve defined one page_load event in aspx page and same page_load event in code behind how will prog run?
Can you explain what inheritance is and an example of when you might use it?
If you want to write your own dot net language, what steps you will you take care?
What is the difference between and ActiveX dll and control?
How to Insert a TextBox value in to Sql database using C# coding?
17 Answers HCL, Sona, TCS,
How many types of cache are there?
What does the "EnableViewState" property do? Why would I want it on or off?
what is difference between const, static and readonly?
List the major built-in objects in asp.net?
Do gac'ed assemblies have fulltrust?