12. Develop a webpage for validation of form fields using regular expressions
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Form Validation: Empty form fields </title>
<style>body{font-family:Verdana;}</style>
</head>
<body>
<script>
function check(myform){
if (myform.myname.value == "" || myform.myname.value == null)
{
alert("Name is mandatory");
return false;
}
if(myform.myphone.value == "" || myform.myphone.value == null)
{
alert("Phone number is mandatory");
return false;
}
else{
return true;
}
}
</script>
<form name="formvalidate" action="formprocess.php"
method="get" onSubmit="return check(formvalidate)">
<p> Name :
<input type="text" size="50" name="myname" /> </p>
<p> Phone No :
<input type="text" size="50" name="myphone" /> </p>
<p>
<input type="submit" value="Submit" />
<input type="reset" value="Clear" />
</p>
</form>
</body>
</html>
<html>
<head>
<title>JavaScript Form Validation: Empty form fields </title>
<style>body{font-family:Verdana;}</style>
</head>
<body>
<script>
function check(myform){
if (myform.myname.value == "" || myform.myname.value == null)
{
alert("Name is mandatory");
return false;
}
if(myform.myphone.value == "" || myform.myphone.value == null)
{
alert("Phone number is mandatory");
return false;
}
else{
return true;
}
}
</script>
<form name="formvalidate" action="formprocess.php"
method="get" onSubmit="return check(formvalidate)">
<p> Name :
<input type="text" size="50" name="myname" /> </p>
<p> Phone No :
<input type="text" size="50" name="myphone" /> </p>
<p>
<input type="submit" value="Submit" />
<input type="reset" value="Clear" />
</p>
</form>
</body>
</html>
Practical Lists with Source Code :
- Writesimple JavaScript with HTML for arithmetic expression evaluation and messageprinting.
- Develop JavaScript to use decision making and looping statements.
- Develop JavaScript to implement Array functionalities.
- DevelopJavaScript to implement functions.
- DevelopJavaScript to implement strings.
- Createa webpage using form elements.
- Createa webpage to implement form event Part-I.
- Createa webpage to implement form event Part-II.
- Developa webpage using Intrinsic Java Function.
- Developa webpage for creating session and persistent cookies observe the effects withBrowser cookie settings.
- Developa webpage for placing the window on the screen and working with child window.
- Developa webpage for validation of form fields using regular expressions.
- Create a webpage with Rollovers Effect.
- Developa webpage for implementing menus.
- Developa webpage for implementing Status bars and Web Page Protection.
- Developa webpage for implementing Slideshow, Banner.