| 12 | | echo $ajax->autoComplete('Message.sendern', '/messages/autocomplete') .'<br />'; |
| 13 | | echo $cU['User']['username'] . " escribe: <br />"; |
| 14 | | echo $form->input('Message.title', array("size" => 35, "maxlength" => 50)) . "<br />"; |
| | 32 | echo $ajax->autoComplete('Message.sendern', '/messages/autocomplete') .'<br />'; |
| | 33 | echo $cU['User']['username'] . " writes: <br />"; |
| | 34 | |
| | 35 | echo $form->input('Message.title', array("size"=>25, "maxlength"=>50)) . '<br />'; |
| | 42 | |
| | 43 | <script type="text/javascript"> |
| | 44 | function validateForm() |
| | 45 | { |
| | 46 | var title = document.getElementById("MessageTitle"); |
| | 47 | var body = document.getElementById("MessageBody"); |
| | 48 | var email = document.getElementById("MessageEmail"); |
| | 49 | |
| | 50 | if (name.value.length < 5) |
| | 51 | { |
| | 52 | alert('Name must have five letters at least'); |
| | 53 | name.focus(); |
| | 54 | return false; |
| | 55 | |
| | 56 | } |
| | 57 | |
| | 58 | if (username.value.length < 5) |
| | 59 | { |
| | 60 | alert('Username must have five letters at least'); |
| | 61 | username.focus(); |
| | 62 | return false; |
| | 63 | } |
| | 64 | |
| | 65 | var space = username.value.indexOf(" "); |
| | 66 | |
| | 67 | //alert('at: ' + atpos); |
| | 68 | |
| | 69 | if ( space > 0 ) |
| | 70 | { |
| | 71 | alert('Username can not contain spaces'); |
| | 72 | username.focus(); |
| | 73 | return false; |
| | 74 | } |
| | 75 | |
| | 76 | //check email |
| | 77 | var atpos = email.value.indexOf("@"); //indexOf find something in your JavaScript string |
| | 78 | var dotpos = email.value.indexOf("."); |
| | 79 | |
| | 80 | //alert('at: ' + atpos); |
| | 81 | |
| | 82 | if ( atpos < 1 || dotpos < 1 || email.value.length < 5) |
| | 83 | { |
| | 84 | alert('Mmmm, this email ' + email.value + ' does not look as a valid email'); |
| | 85 | email.focus(); |
| | 86 | return false; |
| | 87 | } |
| | 88 | |
| | 89 | if (agree.checked == false) |
| | 90 | { |
| | 91 | alert('You must do agree'); |
| | 92 | return false; |
| | 93 | } |
| | 94 | |
| | 95 | return true; |
| | 96 | } |
| | 97 | </script> |