Forum Moderators: open
So I need a small bit of JavaScript to make sure this is the case (as people are still, despite requests, putting in lower values!)
The input bit of the form is below - can the JavaScript be small enough to fit onto that line without needing a whole heap of code?
<input type="text" name="amount" value="25" size=10> If anyone can help, I would appreciate it :)
Many thanks...
<script type="text/javascript">
function verify(val){
if (val <= 25) {
alert("Your number is less than 25, try again");
document.formname.boxname.focus();
}
}</script>
that should do it for you. Put the script in the <head>
<input type="submit" name="submitName" disabled="disabled" /> and in the javascript:
<script type="text/javascript">
function verify(val){
if (val <= 25) {
alert("Your number is less than 25, try again");
document.formname.boxname.focus();
} else {
document.formname.submitName.disabled = false;
}
}</script>
I use client side validation only for "oops" catching - not enough digits in a phone number or zip, bad date format, etc.
Serious validation - duplicate keys, totally bogus entries, have to be validated on the server. For the oops entries, it's not mission critical that the data be correct, the user would be upset later if the phone number he entered showed up as 6 digits, but that's his problem.