Recent News

Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Radio Button Event

Here I have explained the events of radio button with javascript.
Let me explain the scenarion first,
We are having two radio button say radioobtn1 and radiobtn2. If I click on the button 1 then I need to show one DIVor FORM. same as when I click on radiobtn 2. I have given the code for the above scenarion.

<script>
function show()
{
if(document.getElementById('radiobtn1').checked)
{
document.form1.style.display='block';
document.form2.style.display='none';
}
else
{
document.form1.style.display='none';
document.form2.style.display='block';
}
}
</script>


<input type="radio" checked="checked" onClick="javascript:show()" name="radiobtn1" id="radiobtn1" value="radiobtn1" /> Radiobtn1
<input type="radio" name="radiobtn2" onClick="javascript:show()" id="radiobtn2" value="radiobtn2" /> radiobutton2

<form action='#url' name="form1" METHOD='POST'>
<table>
<tr class="displaynone">
<td>THIS IS FORM1
contents goes here
</td>
</table>
</form>


<form action='#url' class="displaynone" name="form2" METHOD='POST'>
<table>
<tr class="displaynone">
<td>THIS IS FORM2:

contents goes here

</td>
</table>
</form>
 
 
Hope this should help for freshers and even for all.....
 
Happy Coding!!!!!!!!!
 
 
 

Email Validation from Codebehind

This is for check the email address from codebehind using regular expression.

if (System.Text.RegularExpressions.Regex.IsMatch(txtNewsletter.Text, "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{1,3})$") == false)
{
Page.RegisterStartupScript("GetType", "<script language='javascript'>alert('Please enter valid email address!')</script>'");
}

Followers

Top Commentators

Recent Comments | Recent Posts


bottom