| 1 | <?php |
|---|
| 2 | echo $javascript->link('fckeditor/fckeditor'); |
|---|
| 3 | echo $html->div(null, $html->image('static/loading.gif', array('alt'=>'Loading')), array('id'=>'charging', 'style'=>'display:none;')); |
|---|
| 4 | |
|---|
| 5 | echo $ajax->div('updater', array('style'=>'margin:6px;padding:7px;')); |
|---|
| 6 | |
|---|
| 7 | echo $ajax->form(null, 'post'); |
|---|
| 8 | ?> |
|---|
| 9 | |
|---|
| 10 | <fieldset> |
|---|
| 11 | <legend>Message to our staff:</legend> |
|---|
| 12 | <p> |
|---|
| 13 | <?php |
|---|
| 14 | echo $form->label('Message.title', __('Title', true)) . $form->select('Message.title', array('Mr.' => 'Mr.', 'Mrs.'=>'Mrs.', 'Miss' => 'Miss', 'Dr.'=>'Dr.', 'Fellow'=>'Fellow'), null, array(), false); |
|---|
| 15 | ?> |
|---|
| 16 | <br /> |
|---|
| 17 | <?php echo $form->input('Message.name', array('size' => 30, 'maxlength' => 40, 'between'=>': ')); ?> |
|---|
| 18 | <br /> |
|---|
| 19 | <?php echo $form->input('Message.email', array("size" => 20, "maxlength" => 45, 'between'=>': ')); ?> |
|---|
| 20 | <br /> |
|---|
| 21 | <p> |
|---|
| 22 | <?php echo $form->label('Message.body', __('Message', true));?><br /> |
|---|
| 23 | <?php echo $form->textarea('Message.body', array('cols'=>15, 'rows'=>5)); ?> |
|---|
| 24 | <?php echo $fck->load('MessageBody', 'Basic', 400, 200); ?> |
|---|
| 25 | <?php echo $form->error('Message.body', 'Body is required.'); ?> |
|---|
| 26 | <br /> |
|---|
| 27 | </p> |
|---|
| 28 | |
|---|
| 29 | <?php echo $ajax->submit(__('Send', true), array("url" => "/messages/fromoutside/", |
|---|
| 30 | "update" =>"updater", |
|---|
| 31 | "before" => "MyFCKObject.UpdateEditorFormValue();", |
|---|
| 32 | "loading" => "Element.show('charging');Element.hide('updater')", |
|---|
| 33 | "complete" => "Element.hide('charging');Effect.Appear('updater')" |
|---|
| 34 | )); |
|---|
| 35 | |
|---|
| 36 | echo $fck->fckAjax(); // Fckeditor hack to work with ajax |
|---|
| 37 | ?> |
|---|
| 38 | </fieldset> |
|---|
| 39 | </form> |
|---|
| 40 | <?php |
|---|
| 41 | echo $ajax->divEnd('updater'); |
|---|
| 42 | |
|---|
| 43 | echo $fck->fckAjax(); |
|---|
| 44 | ?> |
|---|
| 45 | <script type="text/javascript"> |
|---|
| 46 | function chkForm() |
|---|
| 47 | { |
|---|
| 48 | var name = document.getElementById("MessageName"); |
|---|
| 49 | var email = document.getElementById("MessageEmail"); |
|---|
| 50 | |
|---|
| 51 | if (name.value.length < 3) |
|---|
| 52 | { |
|---|
| 53 | alert('The name must have five characters at least'); |
|---|
| 54 | name.focus(); |
|---|
| 55 | return false; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | //check email |
|---|
| 59 | var atpos = email.value.indexOf("@"); //indexOf find something in your JavaScript string |
|---|
| 60 | var dotpos = email.value.indexOf("."); |
|---|
| 61 | |
|---|
| 62 | //alert('at: ' + atpos); |
|---|
| 63 | |
|---|
| 64 | if ( atpos < 1 || dotpos < 1 || email.value.length < 5) |
|---|
| 65 | { |
|---|
| 66 | alert('Mmmm, this email ' + email.value + ' does not look as a valid email'); |
|---|
| 67 | email.focus(); |
|---|
| 68 | return false; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | return true; |
|---|
| 72 | } |
|---|
| 73 | </script> |
|---|