Validation for form thingy - JavaScript Help


new to Javascript. This is supposed to be a validation script so that people will have to fill out all fields before they submit the form. When I upload this to server to my site. it isn't working. Any ideas


Your Car Report | Kansas Vehicles | Nebraska Autos | Missouri Title Info | Iowa Car body { background-image: url(images/images/bluebg.jpg); } #header { background-color: #CCC; height: 500px; width: 600px; margin-top: 0px; margin-right: 500px; margin-bottom: 800px; margin-left: 501px; } #LOGO { height: 98px; width: 232px; margin-top: 200px; margin-bottom: 0px; margin-right: 0px; float: left; background-color: transparent; } #background { background-color: transparent; margin: height: 900px; width: 1400px; } #leftsidebar { background-color: transparent; height: 600px; width: 1400px; margin-top: 200px; margin-right: 500px; margin-bottom: 0px; margin-left: 0px; padding-left: 125px; } #leftfloat { margin: 0px; float: left; height: 590px; width: 300px; } #middlefloat { float: left; margin: 0px; height: 500px; width: 700px; background-color: #fff; } #background { } #logo { float: right; height: 98px; width: 232px; padding-right: 20px; } #middle { margin: auto; height: 465px; width: 650px; margin-top: 20px; background-color: #657489; background-image: url(images/images/mediumbkgd.png); } #about { background-color: transparent; margin: 0px; float: right; height: 488px; width: 250px; padding-right: 20px; padding-top: 50px; } #rightinfo { margin: 0px; float: left; height: 360px; width: 309px; }




     First Name     Last Name             Address       State Choose State Iowa Kansas Missouri Nebraska Oklahoma        Phone                        Email



     VIN #                                                                                                                                                    var frmvalidator = new Validator("form1"); frmvalidator.addValidation("f_name","req","Please enter your First Name"); frmvalidator.addValidation("f_name","maxlen=20", "Max length for FirstName is 20"); frmvalidator.addValidation("l_name","req"); frmvalidator.addValidation("l_name","maxlen=20"); frmvalidator.addValidation("add","maxlen=45") frmvalidator.addValidation("phone","maxlen=12"); frmvalidator.addValidation("phone","numeric"); frmvalidator.addValidation("email","maxlen=50"); frmvalidator.addValidation("email","req"); frmvalidator.addValidation("email","email"); frmvalidator.addValidation("vin","maxlen=17"); frmvalidator.addValidation("vin","req");  

Posted On: Wednesday 2nd of January 2013 12:14:00 AM Total Views:  78
View Complete with Replies

RELATED TOPICS OF JavaScript PROGRAMMING LANGUAGE




Creating Hit Counters for a website

HI!!, can anybody tell me how to create a hit counter using Javascript. The hit counter should increment a number stored in a file (on the site) each time a user visits it. For reference such Hit Counters can be added to Websites built with Microsoft Frontapage (Tools -> Web Components -> Hit Counter).
VIEWS ON THIS POST

180

Posted on:

Monday 19th November 2012
View Replies!

Expand/collapse navigation help

Javascript Expand/Collapse Sample body { font:10pt Verdana; } a { color:blue; } #content { background-color:#dddddd; width:200px; margin-top:2px; } function toggle(id) { var e = document.getElementById(id); if (e.style.display == '') e.style.display = 'none'; else e.style.display = ''; } Nested expand/collapse blocks in tree format Item 1 Sub-item 1 Sub-item 2 Sub-sub-item 1 Sub-sub-item 2 Sub-item 3 Item 2 Sub-item 1 Sub-item 2 Item 3 How to make when i click on a link to expand to close all other opened links.
VIEWS ON THIS POST

173

Posted on:

Wednesday 21st November 2012
View Replies!

Looking for help...script not working correctly

This is for an auction type form. The user would enter their ID then the amount they are bidding, clicking on the submit button to input it into a history window that also stamps the time it was entered. The current bid moves to the top of the list, with the highest bid shown in the high bid window. The issue that I'm having, is that when I click the submit button, the only thing that shows in the history window is only one line with the time stamp only. The time stamp is over written if I input additional bids. The bidID and bidAmount does not show and the bidAmount is not showing in the highBid field.
VIEWS ON THIS POST

107

Posted on:

Wednesday 21st November 2012
View Replies!

High Level ui element J2ME, "Pizza Order"

import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class Intergerate extends MIDlet implements CommandListener { private TextField userName; private TextField password; private TextField lastName; private Command Exit; private Form form; private Command login; private Display display; private TextField name; private TextField phone; private Command submit; List menu; List choose; List psize; List shop; List type; TextBox input; // ticker Ticker ticker = new Ticker( "Welcome to Idehen Pizza, Buy one and get one free! " + " Watchout for our every day low price."); // alerts final Alert soundAlert = new Alert("sound Alert"); public void Intergerate2() { name = new TextField("Name:", "", 10, TextField.ANY); phone = new TextField("Phone:", "", 10, TextField.PHONENUMBER); form = new Form("Pizza Ordering"); submit = new Command("Submit", Command.OK, 2); } public Intergerate() { userName = new TextField("FirstName:", "", 10, TextField.ANY); lastName = new TextField("LastName: ", "", 10, TextField.ANY); password = new TextField("Password: ", "", 10, TextField.PASSWORD); form = new Form("Login to Order Pizza"); Exit = new Command("Exit", Command.EXIT, 2); login = new Command("Login", Command.OK, 2); } // command static final Command backCommand = new Command("Back", Command.BACK, 0); static final Command mainMenuCommand = new Command("Main", Command.SCREEN, 1); static final Command exitCommand = new Command("Exit", Command.STOP, 2); static final Command nextCommand = new Command("Next", Command.OK, 3); String currentMenu; public void startApp() { display = Display.getDisplay(this); form.append(userName); form.append(lastName); form.append(password); form.addCommand(Exit); form.addCommand(login); form.setCommandListener(this); display.setCurrent(form); mainMenu(); } void mainMenu() { display.setCurrent(menu); currentMenu = "Main"; } public void pauseApp() { display = null; choose = null; menu = null; psize = null; ticker = null; form = null; input = null; // textfield = null; shop =null; type =null; } public void destroyApp(boolean unconditional) { notifyDestroyed(); } public void validateUser(String name, String lastName, String password) { if (name.equals("co") && lastName.equals("ide") && password.equals("300")) { ppizza(); } else { tryAgain(); } } public void ppizza() { menu = new List("Select a Menu Items", Choice.IMPLICIT); menu.setTicker(new Ticker("Please choose from the list of menu below!")); menu.append("Pizza shop", null); menu.append("Pizza Type", null); menu.append("Pizza psize", null); menu.append("Toppings List", null); menu.append("Pizza Ordering", null); menu.append("Closed shop", null); menu.append("Restrive Form", null); menu.addCommand(exitCommand); menu.setCommandListener(this); display.setCurrent(menu); } public void tryAgain() { Alert error = new Alert("Login Incorrect", " You entered Wrong \n Username or Password \n \n" + " Please try again", null, AlertType.ERROR); error.setTimeout(Alert.FOREVER); userName.setString(""); lastName.setString(""); password.setString(""); display.setCurrent(error, form); } public void PizzaOrdering() { input = new TextBox("Customer Informatio:", "", 10, TextField.ANY); input.setTicker(new Ticker("Customer Info for Ordring Pizza, Thank you " + "and hope to seeing you again!")); input.addCommand(backCommand); input.addCommand(nextCommand); input.setCommandListener(this); input.setString(""); display.setCurrent(input); currentMenu = "input"; } // Piza Shop locations List component. public void pizzaShop() { shop = new List("Shop Locations", Choice.EXCLUSIVE); shop.setTicker(new Ticker("Pizza Location")); shop.addCommand(backCommand); shop.addCommand(nextCommand); shop.setCommandListener(this); shop.append("Toronto", null); shop.append("Pickering", null); shop.append("Port Union", null); shop.append("Kingston Road", null); shop.append("Pack Avenue, Closed!", null); display.setCurrent(form); display.setCurrent(shop); currentMenu = "shop"; } // Piza type List component. public void type() { type = new List("Pick your Choice", Choice.EXCLUSIVE); type.setTicker(new Ticker("Pizza type List")); type.addCommand(backCommand); type.addCommand(nextCommand); type.setCommandListener(this); type.append("Canadian Pizza", null); type.append("Chinese Pizza", null); type.append("Greek Pizza", null); type.append("Boston Pizza", null); display.setCurrent(form); display.setCurrent(type); currentMenu = "type"; } // Piza Size List component. public void Pizzapsize() { psize = new List("Pizza size", Choice.EXCLUSIVE); psize.setTicker(new Ticker("Pizza Size List")); psize.addCommand(backCommand); psize.addCommand(nextCommand); psize.setCommandListener(this); psize.append("Kids Meal", null); psize.append("Small", null); psize.append("Medium", null); psize.append("Large", null); psize.append("Exra Large", null); display.setCurrent(form); display.setCurrent(psize); currentMenu = "psize"; } public void PizzaToppings() { choose = new List("Select Toppings", Choice.MULTIPLE); choose.setTicker(new Ticker("Topping List")); choose.addCommand(backCommand); choose.addCommand(nextCommand); choose.setCommandListener(this); choose.append("Red Source", null); choose.append("Mushrooms", null); choose.append("Onoins", null); choose.append("Black Olives", null); choose.append("Extra Cheese", null); choose.append("Pineapple", null); display.setCurrent(form); display.setCurrent(choose); currentMenu = "list"; } // Alert component. public void Alert() { soundAlert.setType(AlertType.ERROR); soundAlert.setTimeout(20); soundAlert.setString("** ERROR **"); display.setCurrent(soundAlert); } /** * Location the Form component. */ public void LocationForm() { input = new TextBox("Enter Some Text:", "", 10, TextField.ANY); input.setTicker(new Ticker("Enter Any Text")); input.addCommand(backCommand); input.addCommand(nextCommand); input.setCommandListener(this); input.setString(""); display.setCurrent(input); currentMenu = "input"; } public void commandAction(Command c, Displayable d) { String label0 = c.getLabel(); if(label0.equals("Exit")) { destroyApp(true); } else if(label0.equals("Login")) { validateUser(userName.getString(),lastName.getString(), password.getString()); } String label1 = c.getLabel(); if (label1.equals("Exit")) { destroyApp(true); } else if (label1.equals("Back")) { if(currentMenu.equals("shop")||currentMenu.equals("type")|| currentMenu.equals("psize") || currentMenu.equals("list")|| currentMenu.equals("input") || currentMenu.equals("form")) { // go back to menu mainMenu(); } } else { List down = (List)display.getCurrent(); switch(down.getSelectedIndex()) { case 0: pizzaShop();break; case 1: type(); break; case 2: Pizzapsize();break; case 3: PizzaToppings();break; case 4: PizzaOrdering();break; case 5: Alert();break; case 6: LocationForm();break; } } } } // To login, please check the my code. (co-ide-300) //
VIEWS ON THIS POST

41

Posted on:

Wednesday 21st November 2012
View Replies!

I am trying to understand... AJAX/PHP help.

I am working on a simple click/attack game. I'm trying to understand the ajax parsing involved. HTML: Random Number Attack CSS: *, body { margin:0; padding:0; } body { background:url(rand_bg.png) center top repeat-x; } div { position:relative; } #wrapper { width:600px; margin:7em auto; display:block; } #p_wrap { width:200px; height:100px; padding:20px 0; display:block; overflow:hidden; float:left; background-color:#09C; -moz-border-radius:3px; -webkit-border-radius:3px; -khtml-border-radius:3px; -moz-box-shadow:-1px 2px 5px #999; -webkit-box-shadow:-1px 2px 5px #999; } #c_wrap { width:200px; height:100px; padding:20px 0; display:block; overflow:hidden; float:right; background-color:#F00; -moz-border-radius:3px; -webkit-border-radius:3px; -khtml-border-radius:3px; -moz-box-shadow:1px 2px 5px #999; -webkit-box-shadow:1px 2px 5px #999; } #p_attack { width:100%; height:20px; padding:10px 0 0; text-align:center; font-size:18px; } #c_attack { width:100%; height:20px; padding:10px 0 0; text-align:center; font-size:18px; } .submit { top:20px; text-align:center; margin-bottom:20px; } .att_button { padding:5px; background-color:#09C; cursor:auto; outline:none; } JS: function randNum() { document.getElementById("p_attack").innerHTML=""; return; document.getElementById("c_attack").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("p_attack").innerHTML=xmlhttp.responseText; document.getElementById("c_attack").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","mt_rand.php",true); xmlhttp.send(); PHP: Here's where I'm at... the two extra variables in the PHP script are going to take the place of the simple elseif and be comparative, so as one side can "win". However, right now, I'm simply trying to figure out the most efficient way to parse the $p_att and $c_att to the two corresponding divs through AJAX onclick. If anyone could help explain this to me, that'd be awesome.
VIEWS ON THIS POST

316

Posted on:

Thursday 22nd November 2012
View Replies!

create slides menu

New Perspectives on Javascript Tutorial 4 Review Assignment window.onload = init; var showSlide = null; var timeID = null; var laftPos = 0; function makeMenus(){ var showSlide = new Array(); var allElems = document.getElementsByTagName("*"); for (var i= 0; i< allElems.length; i++){ if (allElems[i].className== "showSlide") showSlide.push(allElems[i]); } for(var i= 0; i< showSlide.length; i++){ showSlide[i].onclick = changeshowSlide; document.getElementById("list1").style.left ="0px"; document.getElementById("head").onclick = closeSlide; document.getElementById("main").onclick = closeSlide; } } I try this code but it not working when i go back to open the sherlock.htm in my web browers, i need help
VIEWS ON THIS POST

146

Posted on:

Thursday 22nd November 2012
View Replies!

IE compatibility issue ....

... Have an issue with the website I'm building. I'm using the prototype library along with scriptaculous.. nothing really fancy or out of the ordinary... There are a few videos to be looked at - it's a website for a wedding films production company (well the wedding films production company a friend and I are creating) - I built the following js class - quite straight forward to dim the page, open the player - a flash player you may already be familiar with ... here is the code with a few comments : var BPPlayer = Class.create({ initialize: function(videoElement) { this.videoWidth = videoElement.width; this.videoHeight = videoElement.height; this.videoFile = videoElement.pathToMovie; this.id = "BPPlayer"; // first, we destroy the player if it already exists ... shouldn't happen, but it doesn't hurt .. just in case this.destroy(); // then we go to the heart of the problem this.DOMcreate(); }, DOMcreate: function() { var fullScreen = new Element("div"); fullScreen.id = this.id; fullScreen.setAttribute("class","curtain"); fullScreen.setAttribute("style","position:absolute;top:0px;left:0px"); //fullScreen.style.display='none'; fullScreen.style.width = $('body').offsetWidth+"px"; fullScreen.style.height = $('body').offsetHeight+"px"; //Effect.toggle(fullScreen,'appear'); // the part above here makes a great big div the background pic is a grey image at about 20% opacity for the dim effect - I commented out the Effect to avoid problems ... // the following part just builds the table that will contain the closing button, the background, the borders, the logo and the container for the player var player = new Element("div"); player.id = "playerContainer"; var x = ( $('body').getWidth() - this.videoWidth ) / 2; /// yeah .. i gave the id "body" to the body player.style.position='absolute'; player.style.left=x+"px"; player.style.top= $('body').scrollTop+120+"px"; player.style.display=''; var table = new Element('table'); table.cellSpacing = 0; table.cellPadding = 0; table.border = 0; table.setAttribute("class",'playerTable'); var row = new Element('tr'); row.height='30px'; var cell = new Element('td'); cell.height = '30px'; cell.width = '30px'; cell.appendChild(this.closeButton()); cell.id = 'top-left'; row.appendChild(cell); var cell = new Element('td'); cell.id = 'top'; row.appendChild(cell); var cell = new Element('td'); cell.width = '30px'; cell.id = 'top-right'; row.appendChild(cell); table.appendChild(row); var row = new Element('tr'); var cell = new Element('td'); cell.width = '30px'; cell.id = 'left'; row.appendChild(cell); var cell = new Element('td'); cell.id = 'player1'; row.appendChild(cell); var cell = new Element('td'); cell.id = 'right'; cell.width = '30px'; row.appendChild(cell); table.appendChild(row); var row = new Element('tr'); var cell = new Element('td'); cell.width = '30px'; cell.id = 'left'; row.appendChild(cell); var cell = new Element('td'); cell.align='center' cell.id = 'player-logo'; cell.innerHTML = ''; row.appendChild(cell); var cell = new Element('td'); cell.id = 'right'; cell.width = '30px'; row.appendChild(cell); table.appendChild(row); var row = new Element('tr'); row.height='30px'; var cell = new Element('td'); cell.height = '30px'; cell.width = '30px'; cell.id = 'bottom-left'; row.appendChild(cell); var cell = new Element('td'); cell.id = 'bottom'; row.appendChild(cell); var cell = new Element('td'); cell.width = '30px'; cell.id = 'bottom-right'; row.appendChild(cell); table.appendChild(row); player.appendChild(table); fullScreen.appendChild(player); $('body').appendChild(fullScreen); // the next 2 commands call the UFO class to create the flash player in the container td defined above var FO = { movie:"./interface/flv_player/flvplayer.swf",width:(this.videoWidth-35),height:this.videoHeight,majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file="+this.videoFile+"&lightcolor=0xFFFFFF&showdigits=true&autostart=true&showfsbutton=false" }; UFO.create( FO, "player1"); }, closeButton: function() { var button = new Element('a'); var img = new Element('img'); button.href='java script:void(0)'; button.setAttribute('onclick','BPPlayerInstance.close()'); img.border=0 img.style.position='relative'; img.style.top='5px'; img.style.left='5px'; img.src='./interface/images/closebox.png'; button.appendChild(img); return button; }, destroy: function() { if($(this.id)) { $(this.id).remove(); } }, close: function() { this.destroy(); } }); the css for curtain (i added the same as in-line style def but it hasn't changed a thing): .curtain { background-image:url('../images/curtain.png'); position:absolute; top:0px; left:0px; } right ... so that works brilliantly in safari 3,4 and FF 2,3 ... but not in IE in IE when the handler is called and an instance of BPPlayer in initialised, the browser viewport just doubles in size and there is nothing in the second half... when i alert the content of the fullScreen element it looks pretty good, everything seems to be where it should be and I managed to get rid of all errors that IE was throwing at me ... but still no luck ... I'm probably using some properties that IE doesn't like .... but I need another set of (skilled) eyes to have a look at it ...
VIEWS ON THIS POST

119

Posted on:

Thursday 22nd November 2012
View Replies!

select onchange with typing in Webkit

In Firefox, IE and Opera, with a select menu with size > 1, typing a few characters in the menu selects an item and triggers the onchange event. In the Webkit-based Safari and Google Chrome, the item appears to be ...
VIEWS ON THIS POST

193

Posted on:

Thursday 22nd November 2012
View Replies!

Related JSP executing

hai, i am having aproblem with jsp while executing. I typed simple hello world progrmm. i have installed j2sdk and apache tomcat.Guide me what to install and what are the necessary steps to run the programm.
VIEWS ON THIS POST

138

Posted on:

Thursday 22nd November 2012
View Replies!

JavaScript Form

I need to create a form, pull the data from the form, and generate a 'Thank You' letter which incorporates various form elements. I have the three page form create but I can't get the 'Next' or 'Submit Registration' buttons to work on the second page or get the form elements to display in the 'Thank You' letter. I am really frustrated and could use some help. Here is my code: Page 1 of 2 Student Registration Form UOP High School - Student Registration Form Student Information: Last Name       First Name       Social Security No.      Birth Date   Street Address      City      State      Zip Code   Family Information: Parent/Guardian Name      Parent/Guardian Name    Emergency Contact (If the parent(s) cannot be contacted): Name      Phone Number     Relationship      Transportation   Yes   No Additional Information: Enter any additional information Page 2 of 2 Student Registration Form UOP High School - Student Registration Form Medical Information: Insurance Provider Policy No. Phone Number Student Interests: What is your child's favorite subject Math Science History Foreign Language Vocational Computers What sports does your child participate in (check all that apply) Football Basketball Baseball Softball Track Field Hockey Tennis Cross Country Swimming Future Interests: What does your child plan to do after graduation Work College Military If you chose college, do you plan on having your child take the PSAT Yes No Additional information or comments Enter any additional information or comments here Whenever I press the button on the second page, I get two javascript errors. See attached. This post has been edited by kevinm1019: 28 October 2006 - 12:13 AM
VIEWS ON THIS POST

171

Posted on:

Friday 23rd November 2012
View Replies!

how to load alexa graphs with javascript

my java scripting is week ..... so i want to ask that i have alexa traffic graphs links and i want to Load them with javascript when use click dee tab ( see image) so how to do that . http://i1102.photobucket.com/albums/g453/darkc99/sss.png
VIEWS ON THIS POST

296

Posted on:

Saturday 24th November 2012
View Replies!

chat box

Any one help me to create a chat box (HTML/JS)for my site. Many web sites provide the chat box which referring their site. I don't want that kind of chat box. I need a complete code for chat with all functions. If i get the code to login with nick name,then that is well enough. I have Ajax chat box code..it has many files.. I don't know how to integrate all those files. I've created the site thru blogger. So,i need a code in HTML/JS so that i can simply copy and paste in my site.
VIEWS ON THIS POST

124

Posted on:

Saturday 24th November 2012
View Replies!

What Is DHTML Script?

Hi , I just wanna know that what Is DHTML Script
VIEWS ON THIS POST

87

Posted on:

Saturday 24th November 2012
View Replies!

I need to have a "Leave a comment" section?

I am driving an html site from my network drive in my office that can be viewd on LAN. I need to put a blog kind of section on my site so people who visite this site can leave there comments on it and all can see thses comments. Can someone help me with this please
VIEWS ON THIS POST

205

Posted on:

Saturday 24th November 2012
View Replies!

CSS 3.0 Background Properties

Folks, I am back with CSS 3.0 background options I hope youll love this one. the details you can find here http://innovator.samsungmobile.com/cms/cnts/knowledge.detail.view.doplatformId=12&cntsId=7400 Some of the details covered the above article: Background (multiple) The css3 gives the possibility to apply more background images to a single element and not just the single one as specified in the css2 property background. Background clip The background-clip property is used to determine whether the background extends into the border or not. The default is border-box, which means it DOES extend into it, but if you set it to padding-box, it doesnt. if you use content-box the background only extends to the content area. Background origin The background-origin CSS property determines the background positioning area (the origin of a background-image). background-origin does not apply when background-attachment is fixed. Background size The background-size property specifies the size of the background images. The contain values scales the image, while preserving its aspect ratio (if any), which may leave uncovered space. The cover scales the image so that it covers the whole area, completely covering the element, but perhaps not showing part of the image if the element and the image did not have the same aspect ratio. You can find full code and details from the above link. Know the new features in easy way. Please share any other good links on CSS 3.0 .
VIEWS ON THIS POST

161

Posted on:

Saturday 24th November 2012
View Replies!

how to properly rewrite this code

I have a jquery slider that is not cross browser compatible. It works in all browsers except FireFox. From reading other forums it says that FireFox needs to read document.getElementByID to properly read the javascritp. Does anyone know a way I can rewrite this code to still make the slider work but make it function in all browsers $(document).ready(function(){ $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true); }); View page here: http://www.flyteusa.com/flyteusa/index1.php
VIEWS ON THIS POST

182

Posted on:

Saturday 24th November 2012
View Replies!

javascript confirm() function problem????

Hi Everyone, I am using javascript code for removing some records. When i am click on delete selected button. I want this should demand one confirm button in which i want if we click OK in confirm box then the record should be removed from database and if i will click on CANCEL button then it should not be removed that record. I have used some code for this but in this case when i click on CANCEL button after that this is also removing records that i does not want. So i am sending code for javascript which i am using for this. Please help me what code i should use for this application. here is code which i am using:---- function validate() { var confirmMessage="Are you sure to Delete these Details from Database ! " ; if(confirm(confirmMessage)==false) { return false; } } and this is delete button which i am using in my code: Please help me what javascript code i should use for this. It is very urgent for me.
VIEWS ON THIS POST

198

Posted on:

Saturday 24th November 2012
View Replies!

javascript Form Validation Libraries

Hi Everyone, I have been looking at ever growing number of Javascript form validation libraries and although a lot of them are very nice, I would like to know whether anyone knows of a library that offers easy input, ie class type validation but with simple alert box validation alerts. If you know of a library can you shoot me a link
VIEWS ON THIS POST

81

Posted on:

Saturday 24th November 2012
View Replies!

Javascript event to reflect the change as per selection?

Hi all.This is part of my code which I am using to edit the record from database.Initially the input boxes show the values from database and if any one of the value is changed, I want to reflect the change according to the changes made in the fields.The code works fine but if I change values in qty,rate or amount, the other values are not changing.Can experts over here tell me whyHere is my code: function tot() { var d=document.getElementById("total").value; var st=Number(d); var e=document.getElementById("vat_amt").value; var tx=Number(e); var f=document.getElementById("cash_discount").value; var ad=Number(f); var g=document.getElementById("vat").value; var vat=Number(g); var h=(st+tx)-ad; document.getElementById("amount").value = Math.ceil(h); var z=vat+100; var y=(st*100)/z; var i=st-y; var result=Math.round(i*100)/100; //returns 28.45 document.getElementById("vat_amt").value =result; } var total = 0; function getValues() { var qty = 0; var rate = 0; var obj = document.getElementsByTagName("input"); for(var i=0; i 0 && rate > 0){obj[i].value = qty*rate;total+=(obj[i].value*1);} else{obj[i].value = 0;total+=(obj[i].value*1);} } } document.getElementById("total").value = total*1; total=0; } Qty Rate Amount > Vat Amt :
VIEWS ON THIS POST

218

Posted on:

Sunday 25th November 2012
View Replies!

iframe contents with jquery

HI all, I want to get the contents of an iframe with jquery doing this code for(var i=0;frames.length;i++){ if(self.parent.frames[i].getSelection().toString()!=""){ var bdy = $(self.parent.frames[i].name).contents().find("body"); alert('iframe:'+ bdy.html()); } } Is there a better way of doing this My goal is getting the iframes selection create a range, extracting its contents, then to create a map element with the selection contents as innerHTML, and insert the node replacing the selection. I can do this with javascript using chrome, but not with ie, so i'm trying to do this with jquery in order for his to work with all browsers. Then I want to do the reverse. Get all map elements in the iframes, replacing the map outerHTML with its innerHTML using jquery.
VIEWS ON THIS POST

228

Posted on:

Sunday 25th November 2012
View Replies!

Loading a element after the document?

I would like to execute some Javascript after the document has loaded and even after the document.onload functions have been executed. Situation: I'm loading a text-edit field through ajax. When the user submits the form, he is redirected to a PHP file. That PHP file redirects him back to "file.php" using header('location: file.php'); What I want to do is to execute some Javascript actions in file.php, but when I print the tags the file id displayed blank - nothing is loaded at all. As soon as I leave them out, the page does get loaded. Any suggestions
VIEWS ON THIS POST

155

Posted on:

Sunday 25th November 2012
View Replies!

Modifying Database without posting to server (e.g.?

I was wondering about the technology used by Facebook and Twitter (those are the obvious and most popular ones). I have realised that when adding a status or a comment or subscribing to a conversation, the page does not actually post to server to modify the database. Actually, on click the page does not load and it seems like all is done on the client-side yet I believe that some sort of data is stored. How is this possible Can anyone help since I would like to use this type of technology Or they using jQuery If yes, then how is the database modified
VIEWS ON THIS POST

172

Posted on:

Sunday 25th November 2012
View Replies!

Can I have a form without having an associated file.

In every book I have on HTML, it shows a database or other file associated with a form. I want to use form elements with JavaScript to control the web pages themselves, without the use of an external file. Can this be done
VIEWS ON THIS POST

189

Posted on:

Sunday 25th November 2012
View Replies!

Rand number doesn't change

I'm intermediate at PHP but new to AJAX. Please tell me what I"m doing wrong. I am trying to make a simple page that gives a random number every time you click. Instead, I get the same number over and over. I guess you have to timestamp the GET file, but I don't know how function loadXMLDoc() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","random.php",true); xmlhttp.send(); } Random Number Here Change Content And the PHP file:
VIEWS ON THIS POST

135

Posted on:

Monday 26th November 2012
View Replies!

rollover effects

hi I'm working my way through a book and the example i'm on is proving to be a bit in-penetrable. Ok, I know there are other simpler ways to achieve the same thing, but this example sets a whole chapter up and so i must do it this way. The code is: /** * Example 22-1 Adding a rollover effect to an image * * * Add a rollover effect to the specified image, by adding event * handlers to switch the image to the specified URL while the * mouse is over the image. * * If the image is specified as a string, search for an image with that * string as its id or name attribute. * * This method sets the onmouseover and onmouseout event-handler properties * of the specified image, overwriting and discarding any handlers previously * set on those properties. * */ function addRollover(img, rolloverURL) { if(typeof img=="string") { //If img is a string, var id = img; //it is an id, not an image img = null; //and we don't have an image yet. //first try looking the image up by id if(document.getElementByID) img = document.getElementByID(id); else if (document.all) img = document.all[id]; //if not found by id, try looking the image up by name. if (!img) img = document.images[id]; //If we couldn't find the image, do nothing and fail silently. if(!img) return; } //if we found an element but it is not an tag, we also fail if(img.tagName.toLowerCase() != "img") return; //remember the original URL of the image var baseURL = img.src; //Preload the rollover image into the browsers cache (new Image()).src = rolloverURL; img.onmouseover = function() {img.src = rolloverURL;} img.onmouseout = function() {img.src = baseURL;} } The book is 3 years old. Questions: After some research I'm thinking (document.all) img = document.all[id]; is deprecated so i can eliminate this and also if (!img) img = document.images[id]; so now my code is: function addRollover(img, rolloverURL) { if(typeof img=="string") { //If img is a string, var id = img; //it is an id, not an image img = null; //and we don't have an image yet. //first try looking the image up by id img = document.getElementByID(id); //If we couldn't find the image, do nothing and fail silently. if(!img) return; } //if we found an element but it is not an tag, we also fail if(img.tagName.toLowerCase() != "img") return; //remember the original URL of the image var baseURL = img.src; //Preload the rollover image into the browsers cache (new Image()).src = rolloverURL; img.onmouseover = function() {img.src = rolloverURL;} img.onmouseout = function() {img.src = baseURL;} } Before I go any further, is this ok
VIEWS ON THIS POST

165

Posted on:

Monday 26th November 2012
View Replies!

Sequential Numbers in Adobe Acrobat

I am trying to create an Acrobat form that a user fills out. Each form must have a unique number and once a form is used, the next number must be in sequence from the previous one. I think a dynamic stamp will work, but I don't know anything about the Java Script that goes with it. Does anyone know how to do this or where I start
VIEWS ON THIS POST

207

Posted on:

Monday 26th November 2012
View Replies!

Faulty Function

QuoteWhen I click to add a player to the team member list, nothing happens - not even my alert... The objective is to add names to the list through the form fields and then submit them to a generic form processor. Can anyone see something that I've missed
VIEWS ON THIS POST

131

Posted on:

Monday 26th November 2012
View Replies!

image swap on mouseover

im trying to do an image swap when a user hovers a mouse over it heres the code i got but for some reason it doesnt work. can any 1 tell me what is wrong with this function ImgOver() { document.quote.go.src = "images/go_on.gif"; } function ImgOut() { document.quote.go.src = "images/go_off.gif"; } and this is in the body
VIEWS ON THIS POST

201

Posted on:

Monday 26th November 2012
View Replies!

JavaScript Help

Hi , I'm a newbbie on javascript... I'm trying to develope a js to compare the first two letters of two fields...
VIEWS ON THIS POST

162

Posted on:

Monday 26th November 2012
View Replies!

Why would this animation only subtract.

I've been messing with this code to make a fade in animation with setTimout. The only thing is addition isn't working on the fade in. A subtraction on a negative works though. This seems strange to me. changeit.style.opacity -= -0.01; works but when it's changed to changeit.style.opacity += 0.01; there's no fade in. It's the only thing I change. My intuition says to me it should work with addition, but maybe there's something I'm not understanding. #letter{ opacity: 0.01; } var count = 0.01; var changit = null; // object counter = function() { changeit.style.opacity -= -0.01; // if this is set to changeit.style.opacity += 0.01; it doesn't work. What count = setTimeout(counter,50); //alert(count); if(count == 100){ setTimeout(function(){ clearTimeout(countit); }, 50); } } init = function() { changeit = document.getElementById('letter'); changeit.style.opacity = 0.01; counter(); // start animating } window.onload = init; Fade in or fade out That is the question. Of course this is all just for Firefox for now. If I put this in something useful I'll change it so it'll work in other browsers later.
VIEWS ON THIS POST

153

Posted on:

Thursday 29th November 2012
View Replies!

How to set default value for select ?

Pending Accepted Rejected For this how to set default value which is there in the variable $appstatus..... It is little bit urgent. Please help me.... MOD EDIT: Added code tags. When posting code...USE CODE TAGS! And we really couldn't care less how urgent it is for you. This post has been edited by JackOfTrades: 25 February 2012 - 04:55 PM
VIEWS ON THIS POST

183

Posted on:

Thursday 29th November 2012
View Replies!

Change a single character in a string

I need to change one character at a known position in a string. In Pascal I would change the P's character of a string S into 'x' with S[P]:='x'; In JavaScript I come no further than S = S.substr(0,P-2)+'x'+S.substr(P) Is ...
VIEWS ON THIS POST

130

Posted on:

Friday 30th November 2012
View Replies!

comp.lang.javascript FAQ - Quick Answers 2008-01-21

comp.lang.javascript FAQ - Quick Answers- 9.88 - 2007-10-12 1 meta-FAQ meta-questions 2 comp.lang.javascript tips 2.1 Which newsgroups deal with javascript 2.2 What questions are off-topic for clj 2.3 What do I have to do before posting to clj 2.4 Why ...
VIEWS ON THIS POST

130

Posted on:

Friday 30th November 2012
View Replies!

Debugging Javascript

Does anyone know a way to debug javascript in IE I usually use mozilla's built in debugger but I have stumbled across a problem that occurs in IE and not Mozilla.
VIEWS ON THIS POST

189

Posted on:

Friday 30th November 2012
View Replies!

Get only elements with text inside

I want to get all the elements (span, paragraphs, div, etc.) that hold text inside, but just text. e.g.: If I had : this is a paragraph this is a paragraph with a div inside this is a div this is a span with a spaninside So I would get just: this is a paragraph this is a div Only the element with no html tags inside.
VIEWS ON THIS POST

137

Posted on:

Sunday 2nd December 2012
View Replies!

External JS Jquery file

Well...I am just wondering how to import the jquery external file. This is what I did. I created a folder to store a html file and an external jquery file. Then the code for importing the jquery file is written like this
VIEWS ON THIS POST

164

Posted on:

Sunday 23rd December 2012
View Replies!

How can i make an object array of class

Hi . i want to make array of objects from class customer > i wrote this code but it didn't work : so what i have to do exactly : function Accountant_program() { var counter=new Array(); for(i=0;i
VIEWS ON THIS POST

109

Posted on:

Sunday 23rd December 2012
View Replies!

Test if JS is enabled.

I'm supposed to take a bunch of browser information & display it in the web page. I've found some resources to show me how to display the browser information (w3schools helped with that). Now I need to show if Javascript is enabled in the users computer. If someone could just point me to a site that shows how to do that, it would probably be better than just telling me. Here's what I have so far (I know I don't really need the variables, but the instructor wants us to use them as frequently as we can): var browser=navigator.appName; var b_version=navigator.appVersion; var platform=navigator.platform; var version=parseFloat(b_version); document.write("Browser name: "+ browser); document.write(""); document.write("Browser version: "+ version); document.write(""); document.write("Platform: " + platform); document.write(""); document.write("Is java enabled: "+ );
VIEWS ON THIS POST

102

Posted on:

Sunday 23rd December 2012
View Replies!

Please wait Loading... - JavaScript Help

again.I have a popup window that executes a function in opener window and closes.Now my question is how to pop a "Please wait while loading..." message until the opener window finish loadingThe function i execute in opener window is just an sql query to show some results.Thank you.
VIEWS ON THIS POST

78

Posted on:

Friday 28th December 2012
View Replies!

Calling jquery functions other then on document ready - JavaScript Help

I am missing some probably trivial understanding regarding when jquery code can be called, and would like some pointers please.the particular example happens to be for a slideshow, but could be any other jquery functionality.So I have this situation where the normal call is on ready like this function onBefore() { $('#output').html("Scrolling image:" + this.src); } function onAfter() { $('#output').html("Scroll complete for:" + this.src) .append('' + this.alt + ''); } $(document).ready(function() { $('.slideshow').cycle({ fx: 'scrollLeft', timeout: 5000, before : onBefore, after : onAfter }); }); I have included the 2 callback functions there but they are not relevant to my question particularlyOk that works perfectly and all occurs as it shouldWhat I actually want is the on ready function to call a getContent() function that loads content to the page and then calls the jqueryall works in terms of the content load, but the jquery call produces an error so I am obviously calling it incorrectlymy ready function just does this and works correctly $(document).ready(function(){ http = getHTTPObject(); http2 = getHTTPObject(); loadContent(); }); the loadContent calls my serverside code by ajax correctly ( no particular reason not to use jquery ajax), but after the call I wish to initiate the slideshow so it looks like this function initSS() { alert('starting'); alert('here'); alert($('.slideshow').length); $('.slideshow').cycle({ fx: 'scrollLeft', timeout: 5000, before : onBefore, after : onAfter }); alert('done'); } function showContent() { if(http.readyState == 4) { alert(http.responseText); eval(http.responseText); initSS(); } } function loadContent() { var url='loadindexcontent.php'; //alert(url); http.open("GET",url, true); http.onreadystatechange=showContent; http.send(null); } the content loads perfectly, just the jquery failsany help would be greatly appreciatedJohn
VIEWS ON THIS POST

70

Posted on:

Monday 31st December 2012
View Replies!

Resetting the DOM in JQUERY - JavaScript Help

WHy does the DOM get corrupted I am only using one library (jQuery) and still I run into issues where simple documented features do not work where I know the code is right. I am not a Javascript guru but would like to know what one does if the DOM is behaving strangely
VIEWS ON THIS POST

19

Posted on:

Tuesday 1st January 2013
View Replies!

returning a value - JavaScript Help

Hi !Passing values within a function or outside a function has always been a problem for me (to understand). Here's what I need help with. I have the following function that should return a value. Just as an fyi... I'm creating a jQuery mobile application (not that it matters for this problem).So I would like to use the value that is returned in another function but can't seem to get at it. If I alert the value inside the for loop it's fine and I get a value. So I know the value does exist.So somewhere else on the page I'm calling alert(getSaleman()); ... the alert returns undefined\t
VIEWS ON THIS POST

105

Posted on:

Tuesday 1st January 2013
View Replies!

Really Simple Calculator Problems - JavaScript Help

,I'm a PHP coder, but my client is getting me out of my comfort zone by doing a bit of javascript. I've got basic functionality set up, but I'm just coming across one issue. The thing they want is a simple percentage calculator, where someone enters a value, a percentage and the site then performs calculations based on these values.It's all working fine, except when you actually physically write a percentage sign. I'm looking for some way of stripping out percentage signs. I tried the replace() function, but that just stopped the calculator working. Any advice appreciated, here's my code:function calculate() { a=Number(document.getElementById("edit-gpcalculatorcost").value); b=Number(document.getElementById("edit-gpcalculatorpercentage").value); b3=b; b2=b3/100; c=a/(1-b2); c2=Math.round(c*100)/100; c3=c2*1.2; c4=Math.round(c3*100)/100; document.getElementById("edit-gpcalculatortotal").value=c4; }
VIEWS ON THIS POST

85

Posted on:

Tuesday 1st January 2013
View Replies!

Can't get preventDefault() to work - JavaScript Help

Trying to familiarize myself with the preventDefault() event. Created a simple page so that when clicking on a url link, it displays a pop up box instead of, by default, opening up the website.When clicking on the link, it still opens the website. I tried using onmouseover instead of onclick and got errors:http://goken68.brink...entDefault.htmlCode: function urlClick(evt) { evt.preventDefault(); alert("You do not have access rights to that website!"); } Click on the link below to see preventDefault() in action: Go to Website
VIEWS ON THIS POST

138

Posted on:

Tuesday 1st January 2013
View Replies!

How to do popup like this - JavaScript Help

I like to use this type of popup to show iportant message, commercial... Attached Files 17150_.png \t228K \t7 downloads
VIEWS ON THIS POST

101

Posted on:

Wednesday 2nd January 2013
View Replies!

JS/Jquery while loop crashing browser - why? - JavaScript Help

Hi GuysTrying to write a while loop to do validate a form. However when i came to testnig out a simple while loop it keeps crashing the browser and i'm not sure why. When i say 'crashes' the browser just endless appears to be loading and i can't refresh the page. Any ideas what is wrong with the following $(document).ready(function () { var i = 0; while(i
VIEWS ON THIS POST

76

Posted on:

Wednesday 2nd January 2013
View Replies!

Refresh parent page on child page close with a twist... - JavaScript Help

i have a parent window that on a php event will open a new child window. This child window is used over various pages and then navigates back to the original page in the child window and thats the problem. Ive got it working so that indeed the parent window does refresh but everytime i use the child window to navigate to another page. I need to be able to do the stuff on the pages in the child window and then go back to the same start page in the child window and close and refersh. Im probably not making much sense..
VIEWS ON THIS POST

95

Posted on:

Wednesday 2nd January 2013
View Replies!

NIC EDIT help - JavaScript Help

i am using nic edit on my text area which all is working expect for when i use the add link buttonwhen i add a link it just displays javascript:nicTemp(); and not the link i think this is part of there code that does not work they havent made it eazy to read var nicLinkButton=nicEditorAdvancedButton.extend({addPane:function(){this.ln=this.ne.selectedInstance.selElm().parentTag("A");this.addForm({"":{type:"title",txt:"Add/Edit Link"},href:{type:"text",txt:"URL",value:"http://",style:{width:"150px"}},title:{type:"text",txt:"Title"},target:{type:"select",txt:"Open In",options:{"":"Current Window",_blank:"New Window"},style:{width:"100px"}}},this.ln)},submit:function(C){var A=this.inputs.href.value;if(A=="http://"||A==""){alert("You must enter a URL to Create a Link");return false}this.removePane();if(!this.ln){var B="javascript:nicTemp();";this.ne.nicCommand("createlink",B);this.ln=this.findElm("A","href",B)}if(this.ln){this.ln.setAttributes({href:this.inputs.href.value,title:this.inputs.title.value,target:this.inputs.target.options[this.inputs.target.selectedIndex].value})}}});nicEditors.registerPlugin(nicPlugin,nicLinkOptions);
VIEWS ON THIS POST

84

Posted on:

Wednesday 2nd January 2013
View Replies!

Include javascript - JavaScript Help

Im trying to include javascript inside javascript but not working for some reasonpage.html function find() { var head= document.getElementsByTagName('head')[0]; var script= document.createElement('script'); script.type= 'text/javascript'; script.src= 'http://site.com/find.js'; script.onreadystatechange = callback; script.onload = callback head.appendChild(script); }; and in find.jsdocument.getElementById("results").innerHTML ="";
VIEWS ON THIS POST

86

Posted on:

Wednesday 2nd January 2013
View Replies!

javascript null error - JavaScript Help

why i am getting b is null error createelement var b = document.getElementById('clickme'), count = 0; b.onclick = function () { count += 1; b.innerHTML = "Click me: " + count; }; click me
VIEWS ON THIS POST

80

Posted on:

Wednesday 2nd January 2013
View Replies!