Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old December 9th, 2008, 09:44 AM   #1
New Member
 

Join Date: Dec 2008
Location: Greece
Age: 29
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 subdee is on a distinguished road
Javascript, PHP, dynamic validation and Submit Button

Hello all. I have an issue which I'm trying to tackle but I can't find which way would be best.

I have the following function in a Javascript file:
Code:
function validate(objName, fieldName, objValue, objValue2)
{
var objOut = document.getElementById('msg_' + fieldName);
var params = "";

if(objName == "field_length")
{
  params = "?field_length=" + objValue;
}
else if(objName == "postal_code")
{
  params = "?postal_code=" + objValue;
}
else if(objName == "phone_number")
{
  params = "?phone_number=" + objValue;
}
else if(objName == "email")
{
  params = "?email=" + objValue;
}
else if(objName == "afm")
{
  params = "?afm=" + objValue;
}
else if(objName == "field_length_no_require")
{ 
  params = "?field_length_no_require=" + objValue;
}
else if(objName == "field_selected")
{ 
  params = "?field_selected=" + objValue;
}

XMLHttp.open('GET', './form_valid.php' + params, true);
XMLHttp.onreadystatechange = function()
{
    if(XMLHttp.readyState == 4 && XMLHttp.status == 200)
    {
        objOut.innerHTML = XMLHttp.responseText;
    }
}
XMLHttp.send(null);
}
and then each function in the php file returns through echo a string which is to be displayed as you can see in innerHtml.

The problem is that I want the Submit button to be disabled only until all fields are valid at which case it will be enabled.

I have thought of returning a variable from PHP and storing it in Javascript to use it in a big if statement but I can't return any variables from what I've searched.

Maybe I'm going about this whole thing wrong. I'd like to avoid validating in Javascript.

Is there any other way to accomplish this?

Or any ideas in general to get what I want out of this?
subdee is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use a graphic as submit button Sporky HTML, XHTML and CSS 2 April 17th, 2007 10:56 AM
Does a submit button have to be in the form itself Sylvester HTML, XHTML and CSS 1 April 17th, 2007 08:14 AM
Submit Button Confirmation brian1971 HTML, XHTML and CSS 6 March 9th, 2007 02:15 PM
Form Submit button Help!!! Aaron1988 HTML, XHTML and CSS 2 November 25th, 2006 09:51 AM
Validation problem with multiple submit buttons celia05es JavaScript 2 September 29th, 2005 04:19 AM


Search Engine Optimization by vBSEO 3.2.0 RC8