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 |
Why is it preferred to not use finalize for clean up?
What is view state and use of it ?
Can action method static?
What is difference Data List and Data Repeater Control ?
For which does this Codebehind="MyCode.aspx.cs" is relevent to ?
Describe briefly what is the role of IIS on an ASP.NET application? What does it for the same application?
0 Answers InfoAxon Technologies,
what do you mean software devlopment ?
What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
Explain one critical mapping?
Your manager has asked you to describe what you would use application variables for. What statement best describes the use of application variables? a) Application Variables are used to keep state for each connected user. b) Application Variables are used to keep state for the web site c) Application Variables are used to keep state for the application on the server d) Application Variables are used to keep state for all applications objects in the web site.
What is the difference between ASP Session State and ASP.Net Session State?
Whats MSIL, and why should my developers need an appreciation of it if at all?