keneso
09-29-2012, 05:33 PM
Hi,
I am trying to add another text field to an existing form with mandatory fields, this extra field should be filled in with a specific text, i.e I accept.
I know the other option would be the check-box, but I want the users to actually type "I accept the terms".
I have added these bits:
accept_terms: {// compound rule - my addition
required: true,
accept: true
},
accept: "<?php echo _ACCEPTTERMS_;?>", // my addition
to this script, but I don't know how to tell it to validate only the "I accept the terms" phrase.
<script type="text/javascript">
$(document).ready(function() {
$("#frmReg").validate({
rules: {
user_firstname: "required",// simple rule, converted to {required:true}
user_lastname: "required",
username: {
required: true,
minlength: 2
},
user_email: {// compound rule
required: true,
email: true
},
accept_terms: {// compound rule - my addition
required: true,
accept: true
},
},
messages: {
user_firstname: "<?php echo _FIRSTNAMEMANDATORY_;?>",
user_lastname: "<?php echo _LASTNAMEMANDATORY_;?>",
username: {
required: "<?php echo _USERNAMEMANDATORY_;?>",
minlength: "<?php echo _MINUSERNAMECHAR_;?>"
},
email: "<?php echo _EMAILVALID_;?>",
accept: "<?php echo _ACCEPTTERMS_;?>", // my addition
}
});
});
</script>
As a curiosity do you think this solution could work as a rudimental captcha?
Thank you
I am trying to add another text field to an existing form with mandatory fields, this extra field should be filled in with a specific text, i.e I accept.
I know the other option would be the check-box, but I want the users to actually type "I accept the terms".
I have added these bits:
accept_terms: {// compound rule - my addition
required: true,
accept: true
},
accept: "<?php echo _ACCEPTTERMS_;?>", // my addition
to this script, but I don't know how to tell it to validate only the "I accept the terms" phrase.
<script type="text/javascript">
$(document).ready(function() {
$("#frmReg").validate({
rules: {
user_firstname: "required",// simple rule, converted to {required:true}
user_lastname: "required",
username: {
required: true,
minlength: 2
},
user_email: {// compound rule
required: true,
email: true
},
accept_terms: {// compound rule - my addition
required: true,
accept: true
},
},
messages: {
user_firstname: "<?php echo _FIRSTNAMEMANDATORY_;?>",
user_lastname: "<?php echo _LASTNAMEMANDATORY_;?>",
username: {
required: "<?php echo _USERNAMEMANDATORY_;?>",
minlength: "<?php echo _MINUSERNAMECHAR_;?>"
},
email: "<?php echo _EMAILVALID_;?>",
accept: "<?php echo _ACCEPTTERMS_;?>", // my addition
}
});
});
</script>
As a curiosity do you think this solution could work as a rudimental captcha?
Thank you