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 are the ways to show data grid inside a data grid for a master details type of tables? If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?
Why does my asp.net file have multiple tag with runat=server?
What is server side routing?
what is value type to reference type
6 Answers AG Technologies, IBM,
Difference between using directive vs using statement?
Why is it important to maintain session state?
Describe how ASP.NET maintains process isolation for each Web application?
what are partial classes and their use?
there is two functions function a and function b like fun a(){.... ..... } fun b() { } in function b i write the coding to add two numbers and i need to dispaly the sum result in function a with out using global variable. how we do?
What is MSIL?
What's the difference between viewstate and sessionstate?
What is customer control and user control?