I have just downloaded jquery numeric plugin and already added jquery library too but still it's not working so if you people can take a look at my code as please :
<head>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.numeric.js"></script>
</head>
<p>How many Questions would you like to have in your form?</p>
<form action="" method="post">
<input class="positive-integer" name="questions" placeholder="Type questions number in digits as e.g 5" style="width:19%;" type="text" />
<input type="submit" name="submit" value="Submit">
</form>
It should have to work on the input as for class="positive-integer" :
<input class="positive-integer" name="questions" placeholder="Type questions number in digits as e.g 5" style="width:19%;" type="text" />
So if you people can please take a look at my code..!
Here is live link to the file as : http://www.huntedhunter.com/php-login/test/questions.php
i can't see this code on view source page add this code on page.
$(function(){
$('.positive-integer').numeric();
})
Demo
You must initialize the plugin in order to make your example work..
Include this in your page
<script type="text/javascript">
$(function() {
$(".positive-integer").numeric()
});
</script>
Related
I have a html button but i am unable to change it background with Jquery.
<html>
<head><script type="text/javascript" src="jquery_2x.js"></script><script type="text/javascript" src="func_btns.js"></script> </head>
<body bgcolor='#454545'><br />
<form method="POST" action="">
<input type="button" value="Button #1" name="sname" class="btn2" /><br/><br />
<input type="button" value="Button #2" name="sclass" class="btn2"/>
</form>
</body>
</html>
and Here is func_btns.js File:
$(document).ready(function(){
$('btn2').css('background-image', 'btna.jpg');
});
Simple JS code work but this peace of code is not working, i have download latest jquery and attach to html page.
Here is the similar topic Setting background-image using jQuery CSS property
Try something like this,
$('.btn2').css('background-image', 'url("btna.jpg")');
Use a . to use class selector , that is $(".btn2")
I am trying to hack a page that requires a "username" and "password". I have created a form and I think it looks good;
<form action="http://hackmefff.co/login">
<input type="hidden" name = "username" value="hacker">
<input type="hidden" name = "password" value="b678jk">
</form>
People have told me that my form looks good and that I need to create a request in javascript. I don't know how to create one because I just started learning javascript yesterday. I have searched on how to create a request of submit, and all I see is functions that look like they are making a form, which I already have, so am confused. How would I send a request to log me into a website, assuming that url exists, and both name and password are correct.
EDIT:
I have formatted the code below because I don't want the page to show any text at all even though am logged in, it should just be blank. But a test page shows that I didn't get logged in;
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>Test page for your custom form</title>
<script type="text/javascript">
function submitform()
{
document.yourform.submit();
}
</script>
</head>
<body>
<form name="yourform" action="http://hackmefff.co/login">
<input type="hidden" name = "username" value="hacker">
<input type="hidden" name = "password" value="b678jk">
</form>
<input type='hidden' name='query' />
</body>
</html>
<html>
<head>
<title>Test page for your custom form</title>
<script type="text/javascript">
function submitform()
{
document.yourform.submit();
}
</script>
</head>
<body>
<form name="yourform" action="http://hackmefff.co/login" method="post">
<input type="hidden" name = "username" value="hacker">
<input type="hidden" name = "password" value="b678jk">
</form>
Search: <input type='text' name='query' />
Login
</body>
</html>
Note that I have modified your form slightly to include a name so that we can reference it from the JavaScript function.
This answer of course assumes that you have to use JavaScript.
You don't need Javascript for that, just add a submit-button to your form:
<input type="submit" value="Submit">
I am trying to make a very simple coding example work, but for an unknown reason, it is not responding.
The example I am trying to replicate is found here: http://jsfiddle.net/karim79/2hw89/1/
It is an answer to the following SO question: Toggle visibility of text box based on status of check box -jQuery
Here is my code. I have embedded another checkbox, to test if I could call a basic onclick-listener-function. It works. The other checkbox is however not reacting when clicked, even though the exact same code works in the example. Do you know why?
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
$(document).ready(function() {
$('#other').change(function() {
alert("Hello World!");
$('#otherrace').toggle(this.checked).focus();
});
});
</script>
<script>
function test(){
alert("Test is working!");
}
</script>
</head>
<body>
<input type="checkbox" name="race" value="other" id="other">Other,
Specify
<br />
<input style="display: none;" type="text" size="25" maxlength="25"
id="otherrace" />
<br />
<input type="checkbox" onclick="test()" name="test" value="test"
id="test">testing
<br />
</body>
</html>
script element cannot have both src and body
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!--or use the address as http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js-->
<script>
$(document).ready(function() {
$('#other').change(function() {
alert("Hello World!");
$('#otherrace').toggle(this.checked).focus();
});
});
</script>
Script.src
This attribute specifies the URI of an external script; this can be
used as an alternative to embedding a script directly within a
document. script elements with an src attribute specified should not
have a script embedded within its tags.
Also, if you are loading the page from a local files system, using a protocol like file://.... then you need to specify the http protocol in the jQuery url like <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
Use
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
I love Parsley's style of form validation with beautfiul background-color at the form elements (green -> correct, red -> wrong), but I can't figure out how to implement this.
I followed the instructions line per line, but it's not working. Maybe my other js resources disturb the flow, so I made a plain new html site, but it also doesn't work either.
What am I doing wrong?
My plain .html looks like that:
<html>
<head>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.0.2/bootstrap.min.js"></script>
<script type="text/javascript" src="pars/parsley.js"></script>
</head>
<body>
<form id="demo-form" data-validate="parsley">
<label for="fullname">Full Name * :</label>
<input type="text" id="fullname" name="fullname" data-required="true" />
<input type="submit" value="ok" />
</form>
</body>
</html>
I'm leaving the field blank, click "ok", and nothing happens.
I was able (don't ask me how) to run Parsley for a short time, but without the fancy background-colors. Do you know what to do?
Parsley does not manage colors / UI. It justs add / remore css classes depending on validation.
By default: parsley-error and parsley-success. They could be changed in parsley config.
But you will have still to do some css to tell that parsley-success for example has green background and parsley-error a red one.
Take a look at this html:
<head>
<title>Test page</title>
<script type="text/javascript">
function submitForm() {
document.getElementById("form2").submit();
}
</script>
</head>
<body>
<form id="form1" name="form1">
<input type="hidden" name="test1" value="test" />
<form id="form2" name="form2" action="http://google.com">
<input type="hidden" name="test2" value="nothing" />
</form>
</form>
Submit
</body>
Thing I want to do is submitting form2 located within form1 with a javascript. I want this to be done by submitForm() function. The problem is that it doesn't appear to work. I'm using FireFox for testing and always get an error which says that it's undefined. Does anybody know how I can get it working? Thanks in advance!
You can't nest HTML forms like that. End form1 before starting form2. Duplicate the hidden input if necessary.
Well, given that you have no element with the ID "xxx", I could see where your script might have some difficulty. Perhaps you mean "form2"?