Home > Web Front-end > JS Tutorial > body text

Js control form field code_javascript skills

WBOY
Release: 2016-05-16 18:52:57
Original
1045 people have browsed it

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]
js verification is Positive integer
The code is as follows:


<script> <br> var re = /^[1-9]d*$/; //Intelligent verification of single characters<br>if (!re.test(document.getElementById('group_order').value)){ <br>alert(" Group order must be numeric!"); <br>document.getElementById('group_order').focus(); <br>return false; <br>} <br></script>
if(value < ;0 || value!=parseInt(value) ){
alert("is not a positive integer");
}else{
alert("is a positive integer");
}


JS sending form (method 1): check_input is a js function, but this method will send all the forms in the page
The code is as follows:


<% form_tag( {:controller=>"transaction",:action=>"check_cid"}, {:name=>"form1",:method=>"post",:multipart=>"true" ,:onsubmit=>”return check_input();”}) do %>
< ;% end %>


JS sending form (method 2): check_original is a js function. This method will send the specified form. Regardless of method 1 or method 2, don’t forget to add return The code is as follows:


<%= form_tag({:controller=>" program",:action=>"index"},{:name=>"newform",:method=>"post",:multipart=>"true"}) %>
< %= submit_tag "Add",{:name=>'newgroup',:onclick=>'return check_original();'} %>
<%= form_tag %>

To be continued............
Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template