/    Sign up×
Community /Pin to ProfileBookmark

Java Script form validation code showing same error

Hi
I am trying to validate a form with different type of message for different error, but you can see [URL=”http://cbsecsnip.in/csnip/form.php”]http://cbsecsnip.in/csnip/form.php[/URL] Here the problem. Please guide me in solving this problem…
Partial Code of form.php-

[CODE]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title>Your Valuable Suggestion</title>
<link rel=”stylesheet” type=”text/css” href=”view.css” media=”all”>
<script type=”text/javascript”>
function notEmpty(elem, helperMsg){
if(elem.value.length == 0){
document.getElementById(‘divforTextBox’).innerHTML = helperMsg;
elem.focus();
return false;
}
document.getElementById(‘divforTextBox’).innerHTML = “”;
return true;
}
</script>
</head>
<body id=”main_body” >
<img id=”top” src=”top.png” alt=””>
<div id=”form_container”
<form id=”form_453570″ class=”appnitro” method=”post” action=”insertform.php”>
<div class=”form_description”>
<h1>cbse cs n ip looks forward for your valuable suggestion</h1>
<p>Please fill all the <font color=”#EC0006″>*</font> marked fields in CAPITAL letters. All <font color=”#EC0006″>*</font> marked fields are mandatory</div>
<ul >
<li id=”li_12″ >
<label class=”description” for=”element_12″>First Name <font color=”#EC0006″>*</font> </label>
<div>
<input id=”element_12″ name=”element_12″ class=”element text large” type=”text” maxlength=”255″ value=”” onblur=”notEmpty(document.getElementById(‘element_12’), ‘Please Enter Your First Name’)”/> <div id=’divforTextBox’></div>
</div>
</li>
<li id=”li_13″ >
<label class=”description” for=”element_13″>Last Name <font color=”#EC0006″>*</font></label>
<div>
<input id=”element_13″ name=”element_13″ class=”element text large” type=”text” maxlength=”255″ value=”” onblur=”notEmpty(document.getElementById(‘element_12’), ‘Please Enter Your Last Name’)”/> <div id=’divforTextBox’></div>
</div>
</li>
<!– Rest of the code –>
<li id=”li_11″ >
<li class=”buttons”>
<input type=”hidden” name=”form_id” value=”453570″ />
<input id=”saveForm” class=”button_text” type=”submit” name=”submit” value=”Submit” />
</li>
</ul>
</form>
<div id=”footer”></div>
</div>
<img id=”bottom” src=”bottom.png” alt=””>
</body>
</html>
[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @vishalonne spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...