Problem in form validation of input using onSubmit

Im trying to check for uploading of files of only doc and ps types. For
that matter I have used two javascript funtions and the form. Im trying
to use onSubmit event handler along with form_for.But the problem is
that, files of any types are getting uploaded.
Can anybody point me out what am I doing wrong here ?


the javascript functions are

the code for form is :

<%= error_messages_for :project %>

  <% form_for :project, :url => {:controller=>:project,:action =>

“create”},:html=>{:multipart => true, :name => “newproject_form”,
:onSubmit => “return validate_form_fields(this);”} do |f| -%>

  <!--form section-->

          <TD HEIGHT=15 COLSPAN=11></TD>
          <TD WIDTH=6 HEIGHT=15></TD>
          <TD width="89" HEIGHT="27">Project Name</TD>
          <TD HEIGHT="27" ><%= f.text_field "name"  %></TD>
          <TD HEIGHT=25>Description</TD>
          <TD HEIGHT=25 align="left"><%= f.text_area "description",

:cols => 40, :rows => 10 %>

Please upload only files that end in: .doc and .ps
        <TD HEIGHT=24>Upload Files  </TD>
          <TD HEIGHT=24 ><%= file_field_tag :file1 %></TD>

          <TD  height="28" >&nbsp;</TD>



Hi everybody,
I have figured it out actually the problem was that the the values were
not getting passed to the javascript method. Now its working.

Now there is another issue i want to know

instead of tag “Create” in <%= submit_tag ‘Create’ %> can i display some
image out there so that when i click on the image the form gets

in html i know we can do something like this

<a href=“javascript:document.newproject_form.submit()”;>

Is there any equivalent in erb ??

image_submit_tag should do it.


On Apr 22, 2:42 am, Saurav C. <rails-mailing-l…@andreas-

Ya I got it yesterday …n now its working fine…nyways thanks for the
Kyle wrote:

image_submit_tag should do it.

Peak Obsession


On Apr 22, 2:42 am, Saurav C. <rails-mailing-l…@andreas-