JavaScript From Question.
I am trying to validate a JS form without getting the alert to show up as a pop up on the page. I want the alert to be displayed inline with the webpage. I believe we need to use 'innerHtml' syntax but I am not sure how.
Also this is there anyway to make the form accept the coupon code in lower case?
Here's my code:
<html>
<head>
<title>Coupon code</title>
<script type="text/javascript">
function isValid(){ var coupon = document.getElementById('coupon').value;
if (coupon == "25OFF")
{alert('Coupon code has been applied.')}
else {alert('Invalid coupon code')} }
</script>
</head>
<body>
<form name="couponField" action="">
Coupon code: <input type="coupon" id="coupon" name="coupon"> <input type="button" value="Apply Coupon Code" onclick="isValid();"> </form> </body> </html>
Below is the code for the effect (the sliding button) that I am trying to achieve:
<html>
<head>
<title>Coupon code</title>
<script type='text/javascript'>
function notEmpty(elem, helperMsg){
var valid = false; if(elem.value.length == 0){ document.getElementById('errorMessage').innerHTML = helperMsg; elem.focus(); }
else{
valid = true; }
return valid; }
</script>
</head>
<body>
<form action='something.php' method='POST' onsubmit="return notEmpty(document.getElementById('coup'), 'Please Enter a Valid Coupon Number')">
Coupon Code: <input TYPE = "text" NAME = "coupon field" id='coup' SIZE = "20" VALUE = ""/>
<span id='errorMessage'></span>
<input type="submit" value="Apply coupon code"/> </form>
</body>
</html>
Thanks in advance for your help!
-
dutrowllc -
Thanks - 1 reply
{{ DiscussionBoard.errors[7194264].message }}-
viescripts -
Thanks - 1 reply
{{ DiscussionBoard.errors[7196270].message }}-
a7521 -
Thanks - 1 reply
{{ DiscussionBoard.errors[7198105].message }}-
viescripts -
[ 1 ] Thanks - 1 reply
{{ DiscussionBoard.errors[7202114].message }}-
Sitesupplier -
Thanks - 2 replies
{{ DiscussionBoard.errors[7205017].message }}-
a7521 -
Thanks - 1 reply
{{ DiscussionBoard.errors[7206876].message }}-
viescripts -
Thanks - 1 reply
{{ DiscussionBoard.errors[7207397].message }}-
a7521 -
Thanks - 1 reply
{{ DiscussionBoard.errors[7207491].message }}-
viescripts -
Thanks - 1 reply
{{ DiscussionBoard.errors[7213096].message }}-
a7521 -
Thanks - 1 reply
{{ DiscussionBoard.errors[7219051].message }}-
viescripts -
Thanks - 2 replies
{{ DiscussionBoard.errors[7220055].message }}-
Sitesupplier -
Thanks - 1 reply
{{ DiscussionBoard.errors[7226735].message }}-
a7521 -
Thanks
{{ DiscussionBoard.errors[7238234].message }} -
-
-
a7521 -
Thanks
{{ DiscussionBoard.errors[7238224].message }} -
-
-
-
-
-
-
-
a7521 -
Thanks
{{ DiscussionBoard.errors[7206900].message }} -
-
-
-
-
-
-
seowonder56 -
Thanks - 1 reply
{{ DiscussionBoard.errors[7233624].message }}-
a7521 -
Thanks
{{ DiscussionBoard.errors[7238238].message }} -
-