
DeepSeek 🤖
New Members-
Posts
7 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
DeepSeek 🤖's Achievements

Newbie (1/5)
0
Reputation
-
I'm making a javascript script to check that the user has filled in the form correctly. Two problems: 1. Email isn't validating properly. 2. I can't seem to get anything except name and email to validate - the other bits just dont do anything. You can see it in action (or not) here: http://names-not-numbers.co.uk/sponsor/ Here is my form <form name="form" id="form" class="form" action="payment.php" onsubmit="return validate(this)" method="post"> <table width="485" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="216" align="right"><label for="name">Full Name:</label></td> <td width="269"><input type="text" name="name" id="name" /></td> </tr> <tr> <td width="216" align="right"><label for="email">Email Address:</label></td> <td width="269"><input type="text" name="email" id="email" /></td> </tr> <tr> <td width="216" align="right"><label for="address">First line of address:</label></td> <td width="269"><input type="text" name="address" id="address" /></tr> <tr> <td align="right"><label for="address2">Second line of address:</label></td> <td><input type="text" name="address2" id="address2" /> </tr> <tr> <td align="right"><label for="city">City:</label></td> <td><input type="text" name="city" id="city" /> </tr> <tr> <td align="right"><label for="county">County:</label></td> <td><input type="text" name="county" id="county" /> </tr> <tr> <td align="right"><label for="postcode">Postcode:</label></td> <td><input type="text" name="postcode" id="postcode" /> </tr> <tr> <td align="right"><label>Are you eligible to pay gift aid?</label></td> <td><input type="radio" name="giftaid" value=1> Yes <input type="radio" name="giftaid" value=0> No <br> </tr> <tr> <td align="right"><label>Payment method</label></td> <td><input type="radio" name="payment" value="online">Online Payment <input type="radio" name="payment" value="cheque"> Cheque <input type="radio" name="payment" value="cash">Cash </tr> <tr> <td colspan="2" align="center"><INPUT name="send_form" type="submit" value="Submit"> </td> </tr> </table> An here's my script function validate(form) { var name = form.name.value; var email = form.email.value; var address = form.address.value; var address2 = form.address2.value; var city = form.city.value; var county = form.county.value; var payment = form.payment.value; var giftaid = form.giftaid.value; var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/; var emailRegex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/; var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim); if(name == "") { inlineMsg('name','You must enter your name.',2); return false; } if(!name.match(nameRegex)) { inlineMsg('name','You have entered an invalid name.',2); return false; } if(email == "") { inlineMsg('email','<strong>Error</strong><br />You must enter your email.',2); return false; } if(!email.match(emailRegex)) { inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2); return false; } if(address == "") { alert("I am here"); inlineMsg('address','Please enter your address.',2); return false; } if(city == "") { inlineMsg('city','Please enter a city.',2); return false; } if(county == "") { inlineMsg('county','You must enter a county.',2); return false; } if(payment == "") { inlineMsg('payment','You must select a payment method.',2); return false; } if(giftaid == "") { inlineMsg('giftaid','Please select one option.',2); return false; } return true; } // START OF MESSAGE SCRIPT // var MSGTIMER = 20; var MSGSPEED = 5; var MSGOFFSET = 3; var MSGHIDE = 3; // build out the divs, set attributes and call the fade function // function inlineMsg(target,string,autohide) { var msg; var msgcontent; if(!document.getElementById('msg')) { msg = document.createElement('div'); msg.id = 'msg'; msgcontent = document.createElement('div'); msgcontent.id = 'msgcontent'; document.body.appendChild(msg); msg.appendChild(msgcontent); msg.style.filter = 'alpha(opacity=0)'; msg.style.opacity = 0; msg.alpha = 0; } else { msg = document.getElementById('msg'); msgcontent = document.getElementById('msgcontent'); } msgcontent.innerHTML = string; msg.style.display = 'block'; var msgheight = msg.offsetHeight; var targetdiv = document.getElementById(target); targetdiv.focus(); var targetheight = targetdiv.offsetHeight; var targetwidth = targetdiv.offsetWidth; var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2); var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET; msg.style.top = topposition + 'px'; msg.style.left = leftposition + 'px'; clearInterval(msg.timer); msg.timer = setInterval("fadeMsg(1)", MSGTIMER); if(!autohide) { autohide = MSGHIDE; } window.setTimeout("hideMsg()", (autohide * 1000)); } // hide the form alert // function hideMsg(msg) { var msg = document.getElementById('msg'); if(!msg.timer) { msg.timer = setInterval("fadeMsg(0)", MSGTIMER); } } // face the message box // function fadeMsg(flag) { if(flag == null) { flag = 1; } var msg = document.getElementById('msg'); var value; if(flag == 1) { value = msg.alpha + MSGSPEED; } else { value = msg.alpha - MSGSPEED; } msg.alpha = value; msg.style.opacity = (value / 100); msg.style.filter = 'alpha(opacity=' + value + ')'; if(value >= 99) { clearInterval(msg.timer); msg.timer = null; } else if(value <= 1) { msg.style.display = "none"; clearInterval(msg.timer); } } // calculate the position of the element in relation to the left of the browser // function leftPosition(target) { var left = 0; if(target.offsetParent) { while(1) { left += target.offsetLeft; if(!target.offsetParent) { break; } target = target.offsetParent; } } else if(target.x) { left += target.x; } return left; } // calculate the position of the element in relation to the top of the browser window // function topPosition(target) { var top = 0; if(target.offsetParent) { while(1) { top += target.offsetTop; if(!target.offsetParent) { break; } target = target.offsetParent; } } else if(target.y) { top += target.y; } return top; } // preload the arrow // if(document.images) { arrow = new Image(7,80); arrow.src = "images/msg_arrow.gif"; }
-
Hi, I've made a form. It looks wrong. You can see it here - http://names-not-numbers.co.uk/sponsor/. Why are the radio buttons all shacked up? CSS: * {margin:0; padding:0} .form {float:left; padding:0 10px 10px 10px; background:#f3f3f3; border:2px solid #cfcfcf} .form label {float:right; width:216px; padding:10px 10px 0 0; font-weight:bold} .form select {float:left; width:269px; margin-top:0px} .form input {float:left; margin-top:0px} .form .submit {clear:both} #msg {display:none; position:absolute; z-index:200; background:url(images/msg_arrow.gif) left center no-repeat; padding-left:7px} #msgcontent {display:block; background:#f3e6e6; border:2px solid #924949; border-left:none; padding:5px; min-width:150px; max-width:250px} HTML: <form name="form" id="form" class="form" action="payment.php" onsubmit="return validate(this)" method="post"> <table width="485" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="216" align="right"><label for="name">Full Name:</label></td> <td width="269"><input type="text" name="name" id="name" /></td> </tr> <tr> <td width="216" align="right"><label for="email">Email Address:</label></td> <td width="269"><input type="text" name="email" id="email" /></td> </tr> <tr> <td width="216" align="right"><label for="address">First line of address:</label></td> <td width="269"><input type="text" name="address" id="address" /></tr> <tr> <td align="right"><label for="address2">Second line of address:</label></td> <td><input type="text" name="address2" id="address2" /> </tr> <tr> <td align="right"><label for="city">City:</label></td> <td><input type="text" name="city" id="city" /> </tr> <tr> <td align="right"><label for="county">County:</label></td> <td><input type="text" name="county" id="county" /> </tr> <tr> <td align="right"><label for="postcode">Postcode:</label></td> <td><input type="text" name="postcode" id="postcode" /> </tr> <tr> <td align="right"><label for="giftaid">Are you eligible to pay gift aid?</label></td> <td><input type="radio" name="giftaid" value=1 checked> Yes <input type="radio" name="giftaid" value=0 checked> No <br> </tr> <tr> <td align="right">Payment method</td> <td><input type="radio" name="payment" value="online" checked> Online Payment <input type="radio" name="payment" value="cheque" checked> Cheque <input type="radio" name="payment" value="cash" checked> Cash </tr> <tr> <td colspan="2"> </td> </tr> </table> And yes, i know theres no submit so far.
-
[SOLVED] Where on earth are these )))))) coming from?
ChrisML123 replied to ChrisML123's topic in PHP Coding Help
you are sexy -
I have made a function, that displays an image and a title in a table. function drawimage($directory, $number, $picturename) //$directory must be in form "image/folder/" { echo '<tr><td><div align="center"><a href="'.$directory.$number.'.JPG" rel="lightbox[group]" title="'.$picturename.'"><img src="'.$directory.'t'.$number.'.JPG" border="0"></a></div></td> <td><div align="left">'.$picturename.'</div></td></tr>)'; } the page that is calling the function has the following text: <table cellpadding="5" cellspacing="0" border="0"> <?php drawimage("image/colour/", 1, "tower"); drawimage("image/colour/", 2, "crazy lights"); drawimage("image/colour/", 3, "a cow"); drawimage("image/colour/", 4, "kettle"); drawimage("image/colour/", 5, "tramway"); drawimage("image/colour/", 6, "snapple"); drawimage("image/colour/", 7, "strasbourg roofs"); drawimage("image/colour/", 8, "swiss woods"); ?> </table> and the images and tables all display fine, except: )))))))) appears just above the images. And i can't work out why! Over to you. you can see it failing in action at http://saltandlightsolutions.com/test/jt/main.php?page=colour
-
I'm trying to write a menu that will automatically change the colour of the active page to red. In this example below, $page is recieved through $_GET, meaning that, in the case of the current page being about.php, $page == "about": The first case statement echos a non clickable red menu item. The second a standard white link. Sadly it doesn't work, either giving me duplicates, or no items at all. Any ideas? switch ($page) { case "about": echo ('<p align="right" class="style2" font color="#ff0000">about the artist</p><p align="right" class="style3">'); echo ('<p align="right" class="style2"><a href="?page=about">about the artist</a></p><p align="right" class="style3">'); case "bandw": echo ('<span class="style3on">b&w</span><br>'); echo ('<a href="?page=bandw">b&w</a><br>'); case "colour": echo ('<span class="style3on">colour</span><br>'); echo ('<a href="?page=colour">colour</a><br>'); } EG 1. where $page=="main", no menus appear at all EG 2. where $page=="about", I get two of every item. Any ideas?
-
brilliant. i know it was way below you, but we all start somewhere! Thanks!
-
i am a complete newbie, making a very basic template get this error when i run the page. any ideas? Parse error: syntax error, unexpected T_ELSE in /home/saltandl/public_html/test/content.php on line 6 Code is below: thanks! <?php if (isset($_GET["title"])){ if (file_exists($_GET["title"].".php")) { include ($_GET["title"].".php");}} else {echo ("Wrong page homie!"); else {include ("home.php"); } ?>