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 |
If i have 1000 records in dataset, how to do paging?
what is wpf and wcf in .net explain with an example?
What does asp stand for in asp.net?
What is css and what is it used for?
What is Web Server Control Templates.?
What is boxing and unboxing in asp.net?
You create an ASP.NET application for a hotel. The application contains a page that displays current weather conditions for the city in which the hotel is located. The application calls an XML Web service every 10 minutes to update the current weather conditions. A new page is then displayed for subsequent requests. You want the same page to be cached and retrieved from the cache during the time between calls to the XML Web service. You decide to use a Page directive to accomplish this goal. Which Page directive should you use? A . <%@ Cache Seconds="600 '' VaryByParam="Page" %> B . <%@ OutputCache Time="600" %> C . <%@ OutputCache Duration="600" VaryByParam="None" %> D . <%@ OutputCache Duration="600" %>
What is role manager work in web.config? how to restrict perticular pages from the users using the role manager?
Why does my asp.net file have multiple tag with runat=server?
What is the difference between adding reference in solution explorer and adding references by using ?
How do you create master pages in asp.net?
Hi All, Im an MCA holder with 3+ years of experience in asp.net. Now i want to move to some good government job. I have no idea about different categories of exams held & which one can be applicable for my education background. I have done B.A with MCA. Please help me out with your valuable suggestions. I would be very grateful. Thanks Anuj