Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
123
rated 0 times [  130] [ 7]  / answers: 1 / hits: 43676  / 14 Years ago, thu, april 8, 2010, 12:00:00

When i submit this form, the values just disappears from the textboxes. I like them to stay printed in the textboxes. How do i do that?



<form id=myform method=get action= onSubmit=hello();>

<input id=hour type=text name=hour style=width:30px; text-align:center; /> :
<input id=minute type=text name=minute style=width:30px; text-align:center; />
<br/>
<input type=submit value=Validate! />
</form>

<style type=text/css>
.error {
color: red;
font: 10pt verdana;
padding-left: 10px
}
</style>
<script type=text/javascript>
function hello(){

var hour = $(#hour).html();
alert(hour);
}
$(function() {
// validate contact form on keyup and submit
$(#myform).validate({
//set the rules for the fild names
rules: {
hour: {
required: true,
minlength: 1,
maxlength: 2,
range:[0,23]
},
minute: {
required: true,
minlength: 1,
maxlength: 2,
range:[0,60]
},
},
//set messages to appear inline
messages: {
hour: Please enter a valid hour,
minute: Please enter a valid minute
}
});


});
</script>

More From » forms

 Answers
132

When you submit a form, the entire page is replaced with the response from the server. If you want to stay on the page (rather than having it replaced by the response), you might look at using jQuery.post or jQuery.ajax to send the form data to the server rather than actually submitting the form.


[#97137] Sunday, April 4, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
chazw

Total Points: 127
Total Questions: 129
Total Answers: 92

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
;