OnlineSolution Forum IndexOnlineSolution Forum Index
OnlineSolution
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups   Register  Register  
Register::  Log in Log in to check your private messages


 Advertisement

Post new topic  Reply to topic
 [ JavaScript / AJAX Q&A ] Javascript « View previous topic :: View next topic » 
Author Message
ileezaa
PostPosted: Tue Apr 13, 2010 12:45 am    Post subject: Javascript Reply with quote



Joined: 09 Apr 2010
Posts: 1

How do I use innerHTML to validate a javascript form? I've created a simple form in Javascript. There are text fields, a password field, and radio buttons. However, I am totally lost on how to validate them using innerHTML. Anyone have any suggestions, hints, or starter code to help me out?
_______________________
affiliateelite ~ affiliateelite.com ~ adgooroo ~ adgooroo.com


Last edited by ileezaa on Thu Apr 15, 2010 10:39 pm; edited 1 time in total
Back to top
View user's profile Send private message
Paul
PostPosted: Tue Apr 13, 2010 6:38 pm    Post subject: Reply with quote

Site Admin

Joined: 10 Dec 2007
Posts: 143
Location: New Zealand

Hi ileezaa.

Can you explain bit more about what you trying to do?

The following code is an example of how you deal with innerHTML by Javascript:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
  <script language="javascript">
    function DisplayInnerHTML()
    {
      var SampleInnerHTML = "";
      var ButtonLabel = "Display InnerHTML";
     
      if( !document.getElementById('innerHTMLForm') )
      {
        // If button is clicked, validate form using InnerHTML
        SampleInnerHTML = "<form name='innerHTMLForm' id='innerHTMLForm'>";
        SampleInnerHTML += "<div>User Name: <input type='text' name='user_name' id='user_name'/></div>";
        SampleInnerHTML += "<div>Password : <input type='password' name='user_password' id='user_password'/></div>";
        SampleInnerHTML += "</form>";
       
        ButtonLabel = "Clear InnerHTML";
      }
     
      document.getElementById('innerHTMLDiv').innerHTML = SampleInnerHTML; //Insert InnerHTML
      document.getElementById('btnDisplayInnerHTML').value = ButtonLabel; // Change button label accordingly
    }
  </script>
</head>
<body>
<input type='button' id='btnDisplayInnerHTML' value='Display InnerHTML' onclick='DisplayInnerHTML();'/>
<br/><br/>
<div id="innerHTMLDiv"></div>
</body>
</html>

_________________
Paul KH Kim

http://www.onlinesolution.co.nz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

 Sponsor Link

Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



OnlineSolution - Since 2007
DAJ Glass (1.0.8) template by Dustin Baccetti
EQ graphic based off of a design from www.freeclipart.nu
Powered by phpBB © 2001, 2005 phpBB Group