How to put validation in custom form

krosty4782 07 Dec, 2012
Hello.
I have this code:

<div title="form_item0" class="form_item" style="border: 0px none ;">
    <div class="form_element cf_heading">
      <h2 class="cf_text">Envie su consulta sin cargo</h2>
       
    </div>
    
   <div class="clear"></div>
  </div>

<div title="form_item1" class="form_item" style="border: 0px none ;">
    <div class="form_element cf_textbox">
      <label class="cf_label" style="width: 100px;">Nombre:</label>
      <input name="Name" id="text_0" size="20" maxlength="25" class="cf_inputbox required validate-alpha" type="text">
      
    </div>

   <div class="clear"></div>
  </div>

<div title="form_item2" class="form_item" style="border: 0px none ; background-color: rgb(255, 255, 255);">
    <div class="form_element cf_textbox">
      <label class="cf_label" style="width: 100px;">Apellido:</label>
      <input name="Phone" id="text_5" size="20" maxlength="25" class="cf_inputbox required validate-number validate-digits" type="text">
      
    </div>

   <div class="clear"></div>
  </div>

<div title="form_item3" class="form_item" style="border: 0px none ;">
    <div class="form_element cf_textbox">
      <label class="cf_label" style="width: 100px;">Email:</label>
<br>
      <input name="Email" id="text_1" size="20" maxlength="25" class= validate['required','email'] type="text">
      
    </div>
   
   <div class="clear"></div>
  </div>


<div title="form_item5" class="form_item" style="border: 0px none ;">
    <div class="form_element cf_textarea">
      <label class="cf_label" style="width: 100px;">Consulta:</label>

<textarea cols="20" rows="12" class="" title="" name="input_textarea_4"></textarea>      
    </div>
   
   <div class="clear"></div>
  </div>


<div id="error-message-input_textarea_6"></div></div><div class="ccms_form_element cfdiv_submit" id="input_submit_71_container_div" style="text-align:center"><input name="input_submit_7" class="" value="Enviar" type="submit" />

   <div class="clear"></div>


I would like to put validation in the first to inputs, and email validation in the 3 input, how do i do this ?

Thanks
GreyHead 07 Dec, 2012
Hi krosty4782 ,

Which version of ChronoForms are you using?
You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6/1.7/2.5.

Bob
krosty4782 07 Dec, 2012
Im using: 4.0 RC3.5.2

Thanks
GreyHead 08 Dec, 2012
Hi krosty4782 ,

Then the classes look like validate['required'] or validate['required','alpha'] or validate['email']

If you need others you can create a little test form with the Wizard, set the validation and then look at the Form HTML that is created.

Bob
krosty4782 08 Dec, 2012
I think im doing something wrong.
I have tried putting validate required and in the form i leave them blank, and click in "submit" button, and it sends the mail no matter that textbox are empty.
I have tried using wizard form with the option in name, "required" and i leave them empty, and again i click submit and the email is send anyway.
What am i doing wrong ?

Thanks
GreyHead 10 Dec, 2012
Hi krosty4782,

Please post a link to the form so I can take a quick look.

Bob
GreyHead 10 Dec, 2012
Hi krosty4782,

The validation is Ok in your form without the template but there is a JavaScript error from the JQuery hover.js file on the page that is breaking the validation. You'll need to fix this error to get the validation to work correctly.

Bob
krosty4782 10 Dec, 2012
How did you find the error ?
I want to know, to find the line with problem and modify it.
Thanks
GreyHead 10 Dec, 2012
Hi krosty4782,

I used the Web Developer tools in my browser - click F12 in most of them - then check the Console tab.

Bob
krosty4782 10 Dec, 2012
I have no errors in hover now (i think), and in "console" there shows no error, but still validation doesnt works.
Any idea?
GreyHead 10 Dec, 2012
Hi krosty4782,

There may still be a conflict with the JQuery library that you are loading :-( Please see this FAQ

Bob
krosty4782 10 Dec, 2012
I have checked the faq and i have putted jquery in no conflict mode.

My console mode only shows the following warnings:

Resource interpreted as Script but transferred with MIME type text/plain: "http://chrome.dealply.com/version_content.js?partner=codecc&channel=codeccp85&appTitle=".
DealPlyStandaloneOptCls.pushScriptTag
DealPlyStandaloneOptCls.start
(anonymous function

)

Resource interpreted as Script but transferred with MIME type text/plain: "http://chrome.dealply.com/chrome_1355045507873/chrome_content.js?sg=&partner=dealplydef&channel=dealplydef".
dealplyVersionPrefixPushScriptTag
(anonymous function)
(anonymous function)
(anonymous function)




But still, can't make it work

Thanks
GreyHead 11 Dec, 2012
Hi krosty4782,

I saw those messages, I'm not sure if they are a problem or not. I don't know where they come from - they certainly aren't form ChronoForms.

Bob
krosty4782 15 Mar, 2013
Well... I couldn't made it work so i let it without validation.
But now it seems like a bot is annoying so i need the validation.
I thought in using a custom javascript validation, but with custom form code i can't change onsubmit event right?

I need to add this:
onsubmit="return validateForm()"

To this:
<form action="http://estudiosolle.com.ar/?chronoform=Consulta1&event=submit" name="Consulta1" id="chronoform_Consulta1" method="post" class="Chronoform"><div title="form_item0" class="form_item"


How can i do that?

Thanks
GreyHead 16 Mar, 2013
Hi krosty4782,

It's not working because your template file loading is a mess.

You have two different versions of JQuery, MooTools More (but not MooTools) loading after the ChronoForms files (it would be better before); and a very old version of MooTools loading much later.

Sort all of this out and your validation will probably work OK.

Bob
krosty4782 16 Mar, 2013
I think i have done what you told me.
Is that right?
Thanks
GreyHead 17 Mar, 2013
Hi krosty4782,

Well it's better but the MooTools library still isn't being loaded.

Bob
krosty4782 18 Mar, 2013
It's working now !
I have added mootools and works fine.
Thanks Bob !
krosty4782 18 Mar, 2013
I'm still getting the blank emails from one ip, i think it's a bot.
How can i do to avoid sending mails from this ip ?
Thanks
GreyHead 18 Mar, 2013
Hi krosty4782,

I've just added some IP blocking code from another thread to this FAQ

Bob
krosty4782 18 Mar, 2013
I checked the faq and i saw i must use: "Submissions from specific IP addresses"
I know also how to code my own code, but i don't know where to put the code using custom chronoform code.
Where are the actions in custom chronoform code?
Thanks
GreyHead 18 Mar, 2013
Hi krosty4782,

You can still open the form in the Wizard and add a Custom Code action.

The Custom Form code only affects the HTML in ChronoForms v4.

Bob
krosty4782 18 Mar, 2013
I think im doing something wrong.
I dont have the actions to add.
This is my screen:

How to put validation in custom form image 1

Thanks
GreyHead 18 Mar, 2013
Hi krosty4782,

In the Easy Wizard there is a code box (maybe two) on the Other tab; to drag actions in you need to switch to the From Wizard.

Bob
krosty4782 18 Mar, 2013

to drag actions in you need to switch to the From Wizard.


I know, but the problem is i can't edit my form with complete form wizard, i can only create a new form.
How to put validation in custom form image 2

If i click in that tab, it shows me the screen i posted before. If i click "Form wizard" it shows standard wizard, but for new forms, there is no option to edit my existing form.

Thanks
krosty4782 19 Mar, 2013
Oh, im so stupid, i haven't noticed that.
Thanks !
This topic is locked and no more replies can be posted.