Write a code for "RequiredFieldValidator" in java script

Answers were Sorted based on User's Feedback



Write a code for "RequiredFieldValidator" in java script..

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

Write a code for "RequiredFieldValidator" in java script..

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

Write a code for "RequiredFieldValidator" in java script..

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

Write a code for "RequiredFieldValidator" in java script..

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

Write a code for "RequiredFieldValidator" in java script..

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

Post New Answer

More ASP.NET Interview Questions

What is shared and private assembly?

1 Answers   Accenture,


What is distributed system in asp.net?

0 Answers  


In which module you have worked in your .net project explain?

1 Answers   TechSolution,


cr8 2 datatables into one dataset DYNAMICALLY (no backend database used like sql,etc.,) with following columns 1st datatable with columns studentNo studentName Deptno 2nd datatable with columns Deptno DeptName DeptAddress add data to both the tables Dynamically and merge these tables into one table and display it in Grid view as studentNo studentName Deptno DeptName DeptAddress

1 Answers   SQL Star,


To which class you load XML or Related Data

1 Answers  






When a dropdownlist has been added by some records and it has been binded why it is not executing i'm facing this error pls help me ? if (is!pageposback) { arraylist books = new arraylist; books.add ("gone with the wind"); books.add ("rahulsriramprakash"); books.add ("vishal"); dropdowndisplay.datasource=books; dropdowndisplay.databind(); } The error is : 1) The dropdowndisplay does not exist.

5 Answers   Netsweeper,


What is MVVM in dot net?

1 Answers   L&T,


how to retrieve property settings from xml .config file.

0 Answers  


When should I use server transfer and response redirect?

0 Answers  


Explain the use of resource manager class in .net.

0 Answers  


how to edit gridview control in asp.net2.0

1 Answers   3i Infotech,


What is the other method, other than GET and POST, in ASP.NET?

3 Answers  


Categories