hi guys ,
i have thee textboxes for contact no.s
viz mob.no,residence no, office no.
and i want that user should enter atleast one no.
so how i can apply client side validation on these text boxes using validators or some other way....
thanks in advance
Loading
Micke BlomqvistPosted Mar 18, 2011, 7:43 AM
You could do it with a small JavaScript. Add the onclick attribute to the button in the Page_Load method, like this:
btnSubmit.Attributes.Add("onclick", "return checkTxtBox();");
Then add the following script to the page or a .js file imported to the page:
(Make sure to change the textbox names to your names)
<script type="text/javascript">
function checkTxtBox()
{
var t1 = document.getElementById('txtNo1').value; // You could also use <% = txtNo1.ClientID %>
var t2 = document.getElementById('txtNo2').value;
var t3 = document.getElementById('txtNo3').value;
if (t1 != '' || t2 != '' || t3 != '')
{
return true;
}
else
{
alert('You need to fill in at least on phonenumber...');
return false;
}
}
script>
Micke BlomqvistPosted Mar 21, 2011, 3:42 PM
Jaganathan BantheswaranPosted Mar 18, 2011, 8:00 AM
Write a java script for validations which includes the one which is given by micke for phone no textbox validation here.
But make micke's function as a part of code in your javascript validation function.
Finally display a model popup with those validation errors on clicking Submit Button .