OnClick And OnKey - How To Handle Form Rules

Sep 16, 2011

Here's the JS:
HTML Code:
$("#select_2").hide();
$("#select").click(function(){
if ($("#option_1").not(":selected")){
$("#select_2").hide();
}
if ($("#option_1").is(":selected")){
$("#select_2").show();
}});

The HTML goes something like
HTML Code:
<select id="select">
<option value="something">something</option>
<option value="something else">something else</option>
<option id="option_1" value="option_1">OPTION 1</option>
</select>

<select id="select_2">
<option value="something">something</option>
<option value="something else">something else</option>
</select>

I have a form that shows a drop down of choices. If the user selects 'OPTION 1' from the list, they are shown another drop down with more choices. The second drop down is hidden by default and shown only if 'OPTION 1' is selected. This works fine when using the mouse, but the user can tab to this field, choose 'OPTION 1', and the next field does not show because of my onclick event handler. Is there a way I can look for either the keyboard or the mouse?

View 3 Replies


ADVERTISEMENT

JQuery :: Validation Dynamic Rules - Add In Rules Dynamically Through The Rules(add) Function After Adding Some Dynamic Fields Through The User Inputs

Sep 6, 2011

I will like to know if there is anyway to view all the rules that I have currently in the Jquery validation plugin. Currently, I am trying to add in rules dynamically through the rules(add) function after adding some dynamic fields through the user inputs. the rules are added in this manner.

[Code]...

View 2 Replies View Related

Rules For Onclick?

Jun 14, 2007

I would like to combine a snippet that captures mouse position with onclick to insert one axis of the mouse position into a variable for form use.

I have the mouse position capture part ok.

Tutorial examples of onclick only explore what the author thinks are
typical uses of onclick.

So I guess I need to study the rules (or ask) for onclick...

What I envision, conceptually (what follows is not correct language-
wise - just look at for concept for now, please).

<A HREF="something"
onClick="VAR A=mouseX)";</A>

If mouse is clicked, I want one of the mouse position variables
defined by a separate mouse capure script insered into another
variable.

Can this be done, and is the HTML or JavaScript standard entry for
onclick the place to learn the rules for this, or is it a
combinational function that I will no find documentation on?

View 3 Replies View Related

Jquery :: Validation Rules AddMethod - PHP Filter For Form

Feb 22, 2011

I have created a php filter for a form that returns an error message if someone uses profanity in the comments field and makes them redo that field before inserting into a database. Here is the code I use for that (I have omitted the lengthy list of profanity..):

Code:
if (isset($_POST['comments'])){
$comments = $_POST['comments'];
$filter=array("badword1", "badword2");
for ($i = 0; $i < count($filter); $i++) { .....
if (preg_match("/".$filter[$i]."/i", $comments)) {
$profanity_msg="Profanity is not allowed";
}}}
//Then this before the form
if(isset($profanity_msg)){
echo $profanity_msg;
}

However, the rest of my form is validated through JQuery Validator and I would like to make a rule that would do the filtering instead of relying on the php. Here is a sketch of what I think I will need to do to build the custom rule, but I am not sure how to write the equivalent function to my php code above.

Code:
$(document).ready(function(){
//custom validation rule - profanity
$.validator.addMethod("profanity",
"Equivalent of my php function goes here..."
);
//validation implementation will go here.
$("#TestForm").validate({
rules: {
comments: {
required: true,
profanity: true
}},
messages: {
comments: {
required: "* Required",
profanity: "* No Profanity Allowed"
}}});
})

View 1 Replies View Related

Jquery :: Re-validate A Validated Form After Checkbox Changed With Different Rules?

Sep 1, 2010

I am trying to validate a form with a couple of elements being required if a checkbox is NOT checked. Now if I submit the form the rules fire - and then I check the checkbox on - the validation rules have already fired - and even though the checkbox is now checked - the validation rules still apply and the form will not submit until I enter the fields.What I was hoping was that the checkbox could toggle the rules on or off.

var validator = $(".cmxform").validate({
rules: {
txtAddress1: {

[code]....

View 1 Replies View Related

JQuery :: Form To Handle Multiple Entries?

Sep 14, 2011

I have a form with 12 fields. This form submits the information for registering a student for courses that we offer. Currently, it only handles one registration at a time and is kind of clunky.I want to present the user the capability to register more than one person at a time. Essentially adding multiple users' info at once before submitting the form.I also want to have an area above the form that shows a list of people that they enter in a select,which will later be modified to have checkboxes so they may remove them, if needed.

View 2 Replies View Related

Script To Handle Form Posting Action?

Jan 28, 2009

I'm trying to create a search form that will post to one of two different URLs (one internal, one external) depending on the selection of a particular field. For some reason, I've never quite got the grasp of javascript ...Basically, the form has two fields. One is the <input='text'> search field, the second would be a <select> field to indicate the type of search to be made (long story, won't go into details here).So let's say the select field name is 'searchType' and the option values are simply '1' and '2'. here's my miserable failed attempt that I reckon is on the right track but with many errors:

Code:

function checkSelect() {
var $internal = 'action="http://www.internalsite.com"';
var $external = 'action="http://www.externalsite.com"';

[code].....

Then in the <form>, I just do an onSubmit="checkSelect()" ?

View 5 Replies View Related

JQuery :: Validation: Form With Multiple Submit Buttons Having Different Validation Rules

Oct 2, 2009

I have a form with multiple fieldsets which are visible conditionally. There are three submit buttons "Abandon", "Save" and "Save & Continue". Each button should validate specific controls of the form and submit it. I tried setting "onsubmit: false" and checking for "$('#myForm').valid ()" on click of these buttons., but that validates all controls of the form.

View 1 Replies View Related

JQUERY :: More Sophisticated Validating Rules - Validating Form Plug

Mar 21, 2010

I am using a validating form plug in for jquery and I have a question about it. Let this function will be an ex.:

[Code]....

'e' is the name attribute of one form element, but can I choose more elements using jquery (CSS) rules like this: input[name*=e] or how can I do something similar?

View 5 Replies View Related

Get Applied CSS Rules?

Aug 11, 2006

Is there any way I can find the CSS rules that were applied to a
particular element? This is distinct from computedStyle - for example,
in Mozilla, I want to find the actual rules that were applied for
font-size, but computedStyle gives me the font-size after weighting it
with the user's text size preference.

View 1 Replies View Related

Form OnClick Output To Be On The Same Page As The Form

Mar 8, 2006

I have forgotten how to do this.

Got a <form ... >
with
<input type="button" name="Hit Me" onclick="whatever()">
</form>

The output of the Javascript function 'whatever' appears on a separate
page. I need it to go below the form on the same page.

View 7 Replies View Related

JQuery :: Checkbox Rules Overlapping ?

Jul 15, 2010

I have 2 checkbox rules that are overlapping.

This one runs first

This one runs second:

So basically the first one runs if BMFNP is checked, and INTEF isn't it checks INTEF and runs the alert. At that time, both are checked so it runs the second function. How can I fix this? I need both to work and display different messages for each situation, if BMFNP is checked, INTEF isn't check INTEF and alert it has been added and BMFNP can only do xxxxx. If both are checked, simply alert that BMFNP can only do xxxx, no need to alert it has been added.

View 2 Replies View Related

JQuery :: Validate() : Assign Rules By Using ID?

Sep 20, 2010

I tried to understand how the pugin works, and I create that code :

$().ready(function() {
$("#TargetEditForm").validate({
rules: {

[code]....

View 1 Replies View Related

Stylesheets - Access Unrecognised CSS Rules?

Feb 8, 2010

I am trying to work out how to access unrecognised CSS properties within stylesheets from JavaScript.

Say I have a stylesheet containing the following:

p {border-radius: 20px;}

Now. The CSS3 "border-radius" property is not recognised by any browsers at the moment. In Internet Explorer I can still access the property as follows:

alert(document.styleSheets[0].rules[0].style['border-radius']); // Alerts "20px"

However, Gecko and V8 don't seem to include the rule in their JavaScript engines at all:

alert(document.styleSheets[0].cssRules[0].cssText); // Alerts "p { }"

Does anyone know of any way to access unrecognised rules in these engines? Or even better if there are any scripts or plugins available anywhere that will do this for me?

View 1 Replies View Related

How To Add Validation Rules For Radio Buttons

Jun 18, 2010

In "validateField" function radio is not exists and I don't know how can I add a validation rule for radio buttons. My code is attached.

View 1 Replies View Related

JQuery :: Remove Rows From Tables According To Some Rules?

Aug 18, 2009

I have a table like this:

<table>
<tr class="item_collection_begin">
<td colspan="3"></td>
</tr>

[Code]....

To sum it up I have a rows that acts a header for a collection of item (class="item_collection_begin). Is there some way to click on a button and then all the items and their header (item_collection_begin), and their footer (item_collection_end, this is not mandatory that they have such one) are all hidden if there is no item in the collection where the cell (amount) is bigger than zero? I have got it to work for all the rows with items: $('#test .amount').filter(function (index) { return $(this).html() == 0; }).parent().remove(); But this does not hide item_collection_begin (and perhabs item_collection_end).

View 1 Replies View Related

JQuery :: Validate - Setting Rules Based On ID Instead Of Name?

Mar 31, 2010

I apologize for posting again - Joern, the developer who built this plugin made a suggestion but I never heard back on a follow up question. I am using validate on a fairly big project. The problem I'm running into is that our e-commerce environment is writing a fairly cumbersome value into each input's name field. It's basically pointing to the form handler. This itself makes it difficult to build rules because the name attribute can be 100 characters long. It's also possible that the path to the form handler will change which is troublesome.

The ideal solution is to have set the validation rules and messaging on the id of the input. Joern indicated that this would be possible, but I need some help going about it.

View 1 Replies View Related

JQuery :: Validator Plugin Rules And Events?

May 21, 2011

how to specify the event in the rule?For example I create a rulejQuery.validator.addMethod("greaterThanZero", function(value, element) { return his.optional(element) || (parseFloat(value) > 0); }, "* Amount must be greater than zero");Iattach this rule to the form$('form').validate({ rules : { amount : { greaterThanZero : true } } });how can I specify when this rule should be checked , for example onChange oronKeypress or when another field is edited. Is it possible to do this as a form validate rule?

View 1 Replies View Related

Rules For Putting A Semicolon At End Of A Line Of Code?

Aug 29, 2009

This may seem like a silly question...

What are the rules for putting a semicolon at the end of a line of code?

View 6 Replies View Related

JQuery :: Dynamic Inputs Targeting For Validation Rules?

May 6, 2011

I'm working on the validation plugin for jquery and trying to figure out how I can target the text boxes that are dynamically generated with this change event. I'm trying to target them so I can set up rules for my page.

[Code]...

View 11 Replies View Related

JQuery :: Create Three Rules Depending On The Path Of A Page

Jun 28, 2009

What I'm trying to do is create three rules depending on the path of a page. If the path contains 'best-sellers', I want jQuery to set the class of the page to 'pm-best-sellers'. I can do this, and it works, but when I add the rules for 'express-gifts' and 'eco-friendly' it breaks.

Here's what I've got:

View 8 Replies View Related

JQuery :: Add Rules To Controls Getting Created Dynamically As Per The Users Wish?

Jun 23, 2010

I have been using the validation plugin for my form validations. The current scenario is thus :

1. I have a form.

2. There is an option for the user to specify a number (Any digit) in one of the textboxes.

3. Depending on the number , i create that many number of textboxes with a particular type of id and name [For Eg: txtEmail_1 , txtEmail_2]

4. Now, these textboxes (all of them) should have to be validated for 'Email','Required', etc.

How do i add rules to these textboxes dynamically??

View 1 Replies View Related

JQuery :: Validate Remove All Rules / Disable Validation?

Aug 22, 2011

I'm using the validation plugin and I have a lot of rules set on my page [code]...

My question, how can I disable all the rules or the entire validation ? I can submit the form via two buttons to either save the page (here I need validation) or "delete" the current view (here I do not want any validation)

View 4 Replies View Related

JQuery :: Adding Rules From JSON For Dynamically Created Controls?

Jan 3, 2012

I'm building all my forms dinamically, calling a web service that returns me the field type, description and a set of rules for validation, all in JSON format. No matter how hard I tried, calling rules("add", ...) after adding the control to DOM does not work since I don't get the right format for the rules. Has anyone tried doing that (returning the rules with JSON and adding to a dynamic control)?

The rules come this way:

data.d[0].ItemRules
minlength:2
required:true

View 1 Replies View Related

JQuery :: .validate Set Required/rules On Textbox Based On Select?

Aug 4, 2011

What I'd like to do is to set the min/max value of a textbox based on what they selected via the <select> which has probably 30 different types...

View 1 Replies View Related

JQuery :: Validation Plugin - Adding Dynamic Custom Rules

Jan 26, 2011

Im using the jquery validation plugin: [URL] The forms are generated dynamically using php, with the standard class 'required' the plugin looks for, however when it comes to adding my custom rules i want them to be dynamic, as the name/id attributes are generated based on what the id of the form is: i.e. the form ID is #comp so an input would have a name attribute of comp_forename, comp_surname so basically the validator is initiated by looking in the body for a form: var form_id = $('body form').attr('id'); Then how can icancatante the strings to created the name attributes dynamically in the rules here:

[URL]

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved