Javascript validation

Ads
 

Javascript validation

View Answers

May 15, 2009 at 11:06 AM

Hi Friend,

<head>
<style type="text/css">
.correct{
background:#00ff00;
}
.incorrect{
background:#f00f00;
}
</style>

<script>
var re = /^\d{5}([\-]\d{4})?$/;
function isValidZipCode(name,msg) {
var nameValue=document.getElementById("name").value;

if(nameValue == '' || nameValue == null ){
document.getElementById("msg").innerHTML='This field is Required';
document.getElementById('name').getAttributeNode('class').value="incorrect";

document.getElementById("name").focus();
return false;
}else
if(!re.exec(nameValue)){
document.getElementById("msg").innerHTML='Enter a valid zip code';
document.getElementById('name').getAttributeNode('class').value="incorrect";
document.getElementById("name").focus();
return false;
}
else{
document.getElementById("msg").innerHTML='Valid';
document.getElementById('name').getAttributeNode('class').value="correct";

}
return true;
}
</script>
</head>
<input type="text" id="name" name="name" class="incorrect">
<div id="msg"></div>
<input type="button" value="Submit" onclick="isValidZipCode(name,msg);">

Thanks

Ads









Related Tutorials/Questions & Answers:
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
Advertisements
javascript validation
javascript validation  my problem is following code is my form i want validation and for email field it will check formate useing regularexpressions. <html> <script src="combovalidate1.js" type="text/javascript
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  i have 4 buttons in my project like save,find,modify,clear and exit. Here my problem is i have to validate in javascript like if i click on save button an alert message should be displayed "DO YOU WANT
javascript validation
javascript validation  I need to validate password with following...;/script> <script language="javascript"> function...;<INPUT id=register type=button value=Submit name=Submit onclick='javascript
javascript for websites url validation
javascript for websites url validation  javascript for websites url validation   JavaScript Code for URL Validation **function isvalidurl(url) { return url.match(/^(ht|f)tps?:\/\/[a-z0-9-.]+.[a-z]{2,4}\/?([^\s<
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
javascript regex validation alphanumeric
javascript regex validation alphanumeric  How to write javascript regex validation for alphanumeric?   <html> <head> <title> alphanumeric validation using regex</title> <script type="text
javascript regex validation email
javascript regex validation email  How to write JavaScript regex validation for email?   <html> <head> <title>Email validation using regex</title> <script type="text/javascript">
simple javascript validation for numbers
simple javascript validation for numbers  simple javascript validation for register number   Here is a html code that accepts number from...; <title>Mobile number validation using regex</title> <script
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
Registration page with JavaScript Validation
Registration page with JavaScript Validation   HTML Registration page with JavaScript Validation - required source code   Registration page in HTML with JavaScript Validation source code <html> <head>
Validation probs in javascript
Validation probs in javascript  This is my sports1.jsp file <...; <HTML> <head> <SCRIPT language="javascript">... file my validation works correctly but when my validation fails i am getting
JavaScript Email Validation
JavaScript Email Validation...; In this section we are going to check email Validation using JavaScript. JavaScript allows to perform a client side validation of email Ids in several forms
how to give validation using javascript in swing
how to give validation using javascript in swing   how to give validation using javascript in swing....... can somebody give code for username and password validation using javscript and swing
Alphanumeric Validation in JavaScript
Alphanumeric Validation in JavaScript In this tutorials we will discuss about alphanumeric validation in JavaScript. Sometimes it may occur when user have.... Alphanumeric validation means a field in the form can accept only numbers
javascript date validation using regex
javascript date validation using regex  Hi, I want to validate the date using javascript. Please help.   <html> <head> <title>Validating Date format</title> <script type="text/javascript">
JavaScript password validation
JavaScript password validation We are going to discuses about JavaScript password special characters validation. In this example we have created one "... used JavaScript password validation and check for an alphabet , number
javascript
javascript  Hi deepak, how to write form validation on javascript
Form Validation With Java Script
the Validation in  JavaScript and  your Validation in JavaScript program... Form Validation With Java Script   .... It is the most important features in JavaScript . It provide the facilities 
URL validation in JavaScript
URL validation in JavaScript In this tutorial we are going to discuss, how to validate a URL in JavaScript. Java Script is a Scripting language. A Java Script language is a lightweight programming language. JavaScript code are written
how do i apply the javascript validation functions to the iframe content?
how do i apply the javascript validation functions to the iframe content?  Hi friends am Yogesh Nandane..Developing a small accessibility evaluation...;script type="text/javascript"> function test() { iframe
how do i apply the javascript validation functions to the iframe content?
how do i apply the javascript validation functions to the iframe content?  Hi friends am Yogesh Nandane..Developing a small accessibility evaluation...;script type="text/javascript"> function test() { iframe
validation
validation  validation
Javascript Form validation Example
Javascript Form validation Example In this section we will discuss about how to validate your application form in javascript. In many applications data... am giving a simple example for form validation using Javascript. Example
validation
Validation method valid the in put. otherwise call the javascript onsubmit to check... code.Ok if you use struts then you can use Validation method valid the in put. otherwise call the javascript onsubmit to check value of radiobutton and file
Javascript
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
Form Validation using Regular Expressions is JavaScript
Form Validation using Regular Expressions is JavaScript... is JavaScript validation using Regular Expressions? The JavaScript Validating... to the lack of useful intrinsic validation functions in JavaScript. JavaScript 1.2 has

Ads