Check if a text box starts with 92 using javascript [closed] - javascript

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
<form name="home" action="" onsubmit="return Validateform();" method="post">
<input type="text" name="receiver" />
<input type="submit" value="send" name="send" />
</form>
What is the javascript to alert if the textbox does not start with 92 on submit?

I recommend you read a JavaScript tutorial. Try here.
To answer your question, this will probably work. If you're wondering why you're getting downvoted - asking people to write your code for you is generally considered bad form, so try not to do this in future. :)
function Validateform(e) {
if (document.getElementsByName('receiver')[0].value.substring(0, 2) !== "92") {
e.preventDefault();
alert("Alert");
}
}

Related

How can I get the value of the checkbox in PHP? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 months ago.
Improve this question
I am trying to make a registration page for my website but when I run it; it gives error. What am I doing wrong?
<?php
//Form values
$name_value=$_POST['Name_input'];
$Username_value=$_POST['Username_input'];
$DOB_value=$_POST['DOB_input'];
$Password_value=$_POST['Password_input'];
$Phone_number_value=$_POST['Phone_number_input'];
$Python_checkbox_value=$_POST['Python_checkbox'];
$Java_checkbox_value=$_POST['Java_checkbox'];
$C_sharp_checkbox_value=$_POST['C#_checkbox'];
$HTML_checkbox_value=$_POST['HTML_checkbox'];
$Cpp_checkbox_value=$_POST['C++_checkbox'];
$R_checkbox_value=$_POST['R_checkbox'];
$swift_checkbox_value=$_POST['swift_checkbox'];
$kotlin_checkbox_value=$_POST['kotlin_checkbox'];
$JS_checkbox_value=$_POST['JS_checkbox'];
Take a look at this code :
<form method="GET">
<input type="checkbox" value="value" name="name">checkbox label</input>
<input type="submit">
</form>
<?php
if (isset($_GET["name"]))
{
echo $_GET["name"];
}
?>
As you can see when I submit the form without checking, the parameter in URI is empty because the checkbox isn't defined (I used GET method)
But when I check it, you can see the parameter is name=value

Try GetElementsByClassName [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
try js ref_doc_getelementsbyClassName
"Uncaught TypeError: Cannot set property 'value' of null "
This HTML code
<input type="text" class="form-control" class="test" />
This JS code
function inputtest() {
document.getElementsByClassName('test').value = selectedControl;
}
Change your html:
<input type="text" class="form-control test" />
JS
function inputtest() {
document.getElementsByClassName('test')[0].value = selectedControl;
}

How to create 'add quantity' input box and embed it inside PHP scripts? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Thanks for those who helped! I have figured it out!
How can I create a input field like the one in the image? And I want to embed it inside $_POST. Thanks for your time :)
This is an HTML5 input of type number. You use it this way:
<form method="POST" action="yourPHPfile.php">
<input type="number" name="number_input">
<input type="submit">
</form>
When this form is submitted, it will send the selected number to yourPHPfile.php and you can retrieve the number from $_POST['number_input']
You can use input for the number selecotr and post using a form like so:
<form method="post">
<input type="number" name="intNumber"/>
<input type="submit" />
</form>
Then in PHP you can do this
<?PHP
if(isset($_POST['intNumber'])){
$myNumber = $_POST['intNumber']; // intNumber is the name of of your input
}
?>
When the submit button the PHP will be fired.
Hope this helps!

Javascript - Clear search output when submitting another text input [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
For my project I need to create a simple search engine for my webpage.
I need a way to clear my previous search results when I submit another search into the form without refreshing the entire page.
My Javascript file contains the objects I am searching for.
HTML:
<form>
<div class="form-group">
<input id="term" class="form-control" type="text">
</div>
<button id="search-button" class="btn btn-default" type="button">
Search</button>
</form>
<div id="results-area"></div>
Correct me if i'm wrong:
Code with jQuery:
$(form).submit(function(e){
$("#results-area").html("");
})
Using jQuery it would go like this:
$("#search-button").click(function(){
// your search function here
$("#term).val('');
});

Using Html input pattern (500/600) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want the following pattern in my Html text box : 500/600
i Have wriiten the following html code for it but its wrong
<input type="text" placeholder="eg: 500/600" name="txtShscpercent" pattern="[0-9]+\.[0-9]+[{\|\}]+[0-9]+" required></td>
can anyone help me with this
Whole numbers:
<input type="text" placeholder="eg: 500/600" name="txtShscpercent" pattern="\d+\/\d+" required>
Decimals:
<input type="text" placeholder="eg: 500/600" name="txtShscpercent" pattern="\d+(\.\d+)?\/\d+(\.\d+)?" required>

Categories