Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get Javascript to work??
#1
I have some javascript that I have used on other websites (made with a different CMS, but not CMS specific javascript) that I have used for required fields on my contact forms. For some reason I can not get it to run in GetSimple. Is there something unique I need to do to get it to run?

Here is my javascript:

Code:
<script type='text/javascript' language='javascript' >
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}
function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required(method,"Please choose a delivery method")==false)
  {method.focus();return false;}
  if (validate_required(company_name,"Please enter your Company Name")==false)
  {company_name.focus();return false;}
  if (validate_required(contact_name,"Please enter your Contact Name")==false)
  {contact_name.focus();return false;}
  if (validate_required(address,"Please enter your Address")==false)
  {address.focus();return false;}
  if (validate_required(city,"Please enter your City")==false)
  {city.focus();return false;}
  if (validate_required(state,"Please enter your State")==false)
  {state.focus();return false;}
  if (validate_required(zipcode,"Please enter your Zipcode")==false)
  {zipcode.focus();return false;}
  if (validate_required(phone,"Please enter your Phone")==false)
  {phone.focus();return false;}
  }
return confirm("Have you entered all your information correctly? Click OK to submit.");
}
</script>

Then I make a form using the field names above (and others)...and call for the javascript like this:

Code:
<form action="registration.php" method="get" name="registrationform" onsubmit="return validate_form(this)">

I am using ScriptInjector to insert the script right before my form. (Although I have put the javascript in the head also, but that didn't work either.)

Attached is an html file of the page source also.

Any ideas?

Thanks!
Reply
#2
I'm no expert with JavaScript but I'm assuming that it's a problem with the code rather than GetSimple. I could be wrong, though.
Reply
#3
Check all paths to files you are using.
Not in the file you edit them, but launch the page in gs and then look at it's source in browser.
It's just your script can't not be launched due to wrong path.

ps. don't forget about debug mode in GS Wink
Addons: blue business theme, Online Visitors, Notepad
Reply




Users browsing this thread: 1 Guest(s)