/    Sign up×
Community /Pin to ProfileBookmark

Form field check and reflect.

I’m new to js, any help appreciated.

I have a form with many numeric fields and its possible value ranges. I need to make a check of the inputted field and reflect by an image at the field if the value is out of its range.

I think to call a function onclick (or there is a better even available?) with value, and range limits, then it checks and shows a little image of that. But! How output the images at the given place at the field, probably every time a user presses the next button?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@s-strongauthorMay 18.2006 — Is it too difficult?!
Copy linkTweet thisAlerts:
@s-strongauthorMay 19.2006 — That's what I do:

[CODE]<html>
<head>
<title></title>
</head>
<body>

<form name="c" method="post">
<table>
<tr>
<td>A</td>
<td align=left><input type="text" name="a" id="a" OnMouseOut="check('a1', 'a2', 'a', 10, 20)"></td>
<td id=a1 style="display:none">Low</td><td id=a2 style="display:none">High</td>
</tr>
<tr>
<td>B</td>
<td align=left><input type="text" name="b" id="b" OnMouseOut="check('b1', 'b2', 'b', 1, 2)"></td>
<td id=b2 style="display:none">Low</td><td id=b2 style="display:none">High</td>
</tr>
</table>

<script language="JavaScript" type="text/javascript">
function check(what, again, name, one, two) {
if(name && name != one && name != two){
if (name<one){
what.style.display = ''
again.style.display= 'none'
}
else{
what.style.display = 'none'
again.style.display = ''
}
}
}else{
what.style.display = 'none';
}
</script>
</form>

</body>
</html>[/CODE]


Here, I just want to make a writting of the check result: Low or High.

All the necessary params I do transfer to the function (which field to display, what are the limits of the range, current value), but as it does not work, please correct me in javascript syntax/logic.
×

Success!

Help @s-strong 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.19,
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,
)...