Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I need to perform client side validation in the view page.I am using asp .net mvc3
My requirement is that, in the form page i have 8 fields.if the user doesnt enter any value and click the search button it should display an alert message with some message
And in case if he enters any value other than which is present in the database it again should display alert message
I am trying this using the following If condition but i wasnt able to display anything.Could any one please help me in this


if ((myForm.getItemValue("Firstname")) != null || (myForm.getItemValue("Lastname")) != null ||
(myForm.getItemValue("City")) != null || (myForm.getItemValue("State")) != null ||
(myForm.getItemValue("Country")) != null || (myForm.getItemValue("College")) != null) {
This is the condition i took in my view page
I am using ajax in my view page
Any one please help me
Thanks
Posted
Comments
The Doer 15-May-12 6:58am    
have you try with getElementById??
Sahi Pinisetty 15-May-12 7:15am    
Just now i tried giving getElementById. It is showing "Object doesn't support property or method 'getItemId'" runtime exception

1 solution

HTML
<script type="text/javascript">

function validate()
{
      if (document.getElementById("<%=tbFirstName.ClientID%>").value=="")
      {
                 alert("Name Field can not be blank");
                 document.getElementById("<%=tbFirstName.ClientID%>").focus();
                 return false;
      }
}
</script>

try this. this might work.
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900