Javascript in smarty template php

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Javascript in smarty template php
astnfan
CZ Newbie
astnfan has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Feb 12, 2005
0.00 posts per day
Posts: 1
Points: 50
   
Hi there,

I am writing a script that will do form validation. The problem that I am running into I think is with the smarty templates I am using on the form page.

Here is the script so far


function checkvalid(){
   username=joinform.signup[username:1:6:16:::username_check].value;
   password=joinform.signup[password:1:6:16:::password_check].value;
   zip=joinform.signup[password:1:6:16:::password_check].value;
   email=joinform.signup[email:1:1:128:::email_check].value;
   letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

   if (username.length == 0 || password.length ==0 || email.length == 0 || zip.length == 0)
   {
      alert("Please Fill Out All Fields");
      return false;      
   }
   if (username == password)
   {
      alert("Username and Password must be different");
      return false;      
   }
   if (letters.indexOf(username.substr(0,1)) == -1)
   {
      alert("Username must start with a letter");
      return false;      
   }
   if (joinform.email.value.indexOf("@")==-1 || joinform.email.value.indexOf(".") ==-1)
   {
      alert("Not a valid e-mail!");
       return false;   
   }
   
   
}//end check valid



Notice how the name value for the form inputs looks like:
signup[username:1:6:16:::username_check] thats how it actually looks on the php file



<form action="signup.php" method="POST" onsubmit="return checkvalid() " id="joinform">

<input type="hidden" name="site" value="{$smarty.request.site}">
<input type="hidden" name="program" value="{$smarty.request.program}">
<input type="hidden" name="campaign" value="{$smarty.request.campaign}">
<input type="hidden" name="nats" value="{$nats_code}">
<input type="hidden" name="step" value="2">
<input type="hidden" name="username" value="{$vars.username}">
<input type="hidden" name="signup[rename_old_member]" value="1">


<TR>
   <TD class="join_name">Username:</TD>
   <TD class="join_value">
      <input class="join_input" type="text" name="signup[username:1:6:16:::username_check]" value="{$vars.username}">
      <span class="whitetext10">Min. 6 Characters</span>
      <span class="join_error">{if $errors.username}<br>{$errors.username}</span>{/if}
   </TD>
</TR>
<TR>
   <TD class="join_name">Password:</tD>
   <TD class="join_value">
      <input class="join_input" type="text" name="signup[password:1:6:16:::password_check]" value="{$vars.password}">
      <span class="whitetext10">Min. 6 Characters</span>
      <span class="join_error">{if $errors.password}<br>{$errors.password}</span>{/if}
   </TD>
</TR>
<TR>
   <TD class="join_name">E-Mail:</TD>
   <TD class="join_value">
      <input class="join_input" type="text" name="signup[email:1:1:128:::email_check]" value="{$vars.email}">
      <span class="join_error">{if $errors.email}<br>{$errors.email}</span>{/if}
   </TD>
</TR>
<TR>
   <TD class="join_name">ZIP (Postal Code):</TD>
   <TD class="join_value">
      <input class="join_input" type="text" name="signup[zip:1]" value="{$vars.zip}">
      <span class="join_error">{if $errors.zip}<br>{$errors.zip}</span>{/if}
   </TD>
</TR>
{if $vars.country}{assign var=country value=$vars.country}{else}{assign var=country value="US"}{/if}
<TR>
   <TD class="join_name">Country:</TD>
   <TD class="join_value">
      <select class="join_select" name="signup[country]">{html_options options=$countries selected=$country}</select>
   </TD>
</TR>
<TR>
   <TD class="join_name">Membership:</TD>
   <TD class="join_value">
      <select name="signup[optionid]" class="join_select">
         {html_options options=$join_options selected=$vars.optionid}
      </select>
      <span class="join_error">
      {if $errors.optionid}<br>{$errors.optionid}
      </span>{/if}



The script keeps returning an error and I am confused as to what is wrong and how to solve it. Any help is much appreciated. Thanks!


Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

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
You cannot attach files in this forum
You cannot download files in this forum