ref: refs/heads/master
commit dcef8b003033dd59f3957d0b6e84cbc1bc47568f
Author: Josef Reidinger
Date: Tue Aug 4 09:03:25 2009 +0200
add input value validator directly to view as js
---
.../systemtime/app/views/system_time/index.rhtml | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/plugins/systemtime/app/views/system_time/index.rhtml b/plugins/systemtime/app/views/system_time/index.rhtml
index c3079a8..f304f05 100644
--- a/plugins/systemtime/app/views/system_time/index.rhtml
+++ b/plugins/systemtime/app/views/system_time/index.rhtml
@@ -7,7 +7,21 @@
});
<% end -%>
-
+
+ <% javascript_tag do -%>
+ function submitTime() {
+ if (!$("#date_date")[0].value.match( /^\d{2}\/\d{2}\/\d{4}$/)){
+ alert ("<%= _("Invalid date format. Correct one is dd/mm/yyyy") %>");
+ return false;
+ }
+ if (!$("#currenttime")[0].value.match( /^\d{2}:\d{2}:\d{2}$/)) {
+ alert ("<%= _("Invalid time format. Correct one is hh:mm:ss") %>");
+ return false;
+ }
+ Element.show('progress');
+ return true;
+ };
+ <% end -%>
<%= javascript_include_tag :defaults %>
<% disabled = ! @permissions[:write] %>
@@ -98,7 +112,7 @@
</tr>
</table>
<p>
- <%= submit_tag _("Save"), :onclick=>"Element.show('progress')",
+ <%= submit_tag _("Save"), :onclick=>"return submitTime()",
:disabled=> disabled, :class => 'button' -%>
</p>
<% end %>
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org