Posts

Showing posts from February 26, 2013

Html code for check box

<HTML> <HEAD> <TITLE>JavaScript - Reading Checkboxes and Radio Buttons</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function showBoxes(frm){    var message = "Your chose:\n\n"    //For each checkbox see if it has been checked, record the value.    for (i = 0; i < frm.Music.length; i++)       if (frm.Music[i].checked){          message = message + frm.Music[i].value + "\n"       }    //For each radio button if it is checked get the value and break.    for (var i = 0; i < frm.Performer.length; i++){       if (frm.Performer[i].checked){          message = message + "\n" + frm.Performer[i].value          break       }    }    alert(message) } //NOTE THE onClick="" emp...

Html code for email validiation_1

<html><head> <script> function validateForm() { var x=document.forms["myForm"]["email"].value; var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (atpos<=1 || dotpos<atpos+2 || dotpos+2>=x.length)   {   alert("Not a valid e-mail address");   return false;   }   else   {         alert("valid email");    } } </script> </head> <body> <form name="myForm" onSubmit="return validateForm();" method="post"> Email: <input type="text" name="email"> <input type="submit" value="Submit"> * </form> </body>

Html code for email validiation

<html> <head> <script> function validate(form_id,email) {    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;    var address = document.forms[form_id].elements[email].value;//alert(reg.test(address));    if(reg.test(address) == false) {       alert('Invalid Email Address');       return false;    } } </script> </head> <body> <form id="form_id" method="post" action="action.php" onSubmit="javascript:return validate('form_id','email');">    <input type="text" id="email" name="email" />    <input type="submit" value="Submit" /> </form> </body> </html>

Html code for index

<html> <body> <form action="test.php" method="get"  >   <input type="text" name="name" /> <input type="submit" value="click"/> </form> </body> </html>