 |
 |
I want to force users to enter dates in a textbox as mm/yyyy
The following works:
<html>
<head>
<title></title>
<script type="text/javascript" >
function testFormat(v) {
var re = new RegExp(document.getElementById("txtR").value);
if (v.match(re) && (v.length==7)) {alert('ok');} else { alert('oops');}
}
</script>
</head>
<body ><form runat="server" id="Form1">
<input type="text" id="txtR" value="^([1-9]|1[0-2]|0[1-9])/(\d{4})$" style="width:200px;" />
<br />
<input type="text" id="txtA" onblur="testFormat(this.value)" style="width:100px;" />
</form></body>
</html>
However:
- Why does the commented out javascript line not work? Instead I have to use this silly workaround of putting the regular expression in a text field, (well, I can make this hidden) and reference that. It's the only way I can make it work - but it's daft.
- In order to force a 2-digit month, I have added the test for v.length==7 - but it must be possible to amend the regex to check for this? Damned if I can see how...
|
|
|
|
 |
Message Removed
modified 2 days ago.
|
|
|
|
 |
Ta - but it still doesn't work. Not sure either how that particular modifier would help anyway?
|
|
|
|
 |
Try this:
<script type="text/javascript">
function testFormat(v) {
var re = new RegExp(/^(1[0-2]|0[1-9])[/]{1}([2-9]\d[1-9]\d|[1-9]\d)$/);
if (v.match(re)) { alert('ok'); } else { alert('oops'); }
}
</script>
Should also take care of your "7" problem
modified 2 days ago.
|
|
|
|
 |
Consider yourself raised to "Hero" status!
IDK how anyone gets their head round regular expressions. I don't pretend to be a genius, but I like to think I'm reasonably intelligent, but regex's defeat me. I'd have more chance solving a Rubik's cube blindfold.
Thank you.
|
|
|
|
|
 |
Ta - Not being funny, but you didn't have a grandad (?) who was a Latin teacher by any chance did you? I had a Peter Kornfield teaching that to me way back in the 60's/70's..... (least, I'm pretty sure it was 'Peter'.) He was an alright bloke...
|
|
|
|
 |
I definitely had a grandfather , but he was a travelling salesman of textiles...However I'm not sure he ever got to the UK, and in the 60s/70s he was clsoe to 60/70 as he was born in 1904...
(What funny is that as a travelling salesman he spoke 7 languages - not including Latin, which he has learned in school but never used)
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
 |
Yeah, well I had two!! OK, not him then. He was interesting - he had a gammy leg as a resuilt of some Nazi 'experiments' which he was unfortunate enough to be caught up in, but fortunate enough to survive. IDK the full story, being only a schoolboy at the time. But he had to spray some kind of medication on it even all these years later which used to stink to high heaven. But we all got used to it. He actually died in my last year there. Never forget his lessons, though can't say I've had much use for Latin either! Suppose it's sort of useful sometimes thinkng about the etymology of words....
|
|
|
|
 |
Wombaticus wrote: resuilt of some Nazi 'experiments' My grandfather too survived one of those horrible things, they called it Auschwitz...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
 |
Although you've got a solution, I can't obviously see that anyone's given you an explanation why the commented out line doesn't work.
var re = new RegExp("^([1-9]|1[0-2]|0[1-9])/(\d{4})$");
In Javascript strings[^], the backslash (\ ) is used to escape the following character. As a result, your pattern actually comes out as:
^([1-9]|1[0-2]|0[1-9])/(d{4})$
That's looking for the literal character "d ", not the digits character class "\d ".
You can solve it by either escaping the backslash within the string:
var re = new RegExp("^([1-9]|1[0-2]|0[1-9])/(\\d{4})$");
or using a regular expression literal:
var re = /^([1-9]|1[0-2]|0[1-9])\/(\d{4})$/;
NB: For a regular expression literal you have to escape the forward-slash (/ ) character, since that's also used to terminate the literal.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
 |
We've got jQuery, if I want to put something somewhere I just go
<div id=a_field_name></div>
not quite as nice as
<% a_field_name %>
or even
{{a_field_name}}
but has the significant advantage of being in the DOM, and is trivial yet very flexible to assign.
i.e less proper code, and HTML is always orrible anyway. That's why we write templating systems, so we can give it to someone else, right ?.
With forms, the job is even easier, and the need for YATS even less clear. Why should you need to go
<input id=a_field_name value={{a_field_name}}>
when this is clearly sufficient
<input id=a_field_name>
and just as trivial as before to assign.
I also have lots of other stuff I need to do with forms, such as attaching the appropriate field handlers and selector widgets, things which should be implicit where possible but ideally can be overridden by the UI designer. I am thinking about reading my hibernate XML definition files, which I believe you can load into their own DOM and access with jquery, to decide on field length, and type and hence the handler, and "not null" etc.
There is a library here http://davestewart.io/plugins/jquery/jquery-populate/ but I am concerned that nothing has happened for 5 years. Are there any other libraries that populate, and read, form data and may be tackle assigning event handlers.
|
|
|
|
 |
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
.style1
{
width: 443px;
height: 181px;
}
.style2
{
width: 154px;
}
.style3
{
width: 132px;
}
</head>
<body style="height: 247px; width: 781px">
<form id="form1" runat="server">
</form>
</body>
</html>
|
|
|
|
 |
Within some javascript I want to be able to go something like
#include "file1.js"
and for that to get evaluated/included/inserted at retrieval time (but cached ideally) and recursively, i.e. for file1.js to have includes of its own, and for duplicate requests to be skipped. Just like the C Preprocessor would do.
So I am about to do precisely that, wire up cpp as a cgi and fetch my javascript through that. Using apache html SSI looks messy, or messier.
For distribution I just make a call to the webserver for my top level file and save the response.
Are there better ways of doing this ?.
modified 13-Apr-15 9:42am.
|
|
|
|
 |
I set my name properly. I am at second phase of development of my first javascript. I'm ready to start factoring out some good stuff I've done and package it off nicely.
So I need to read all this
RequireJS
And I presume I then useMinify
Edit: No, there's a thing called uglify in requirejs.
Basically the answer to my question is "yes there is, we're all using requirejs. go learn".
modified 14-Apr-15 7:15am.
|
|
|
|
|
 |
Need a lot more info.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
I have an application deployed on one server and from this server I want to pop up a new window, which will open a asp.net page deployed on any other server, using window.open() and I want to pass parameters to this pop up window. I don't want to pass parameters through URL. Need some way to pass parameter in a hidden or more secure way.
Can anyone suggest how this can be done.
Thanks in advance.
|
|
|
|
|
 |
first we r finding the grid
like this
var grd=document.getElementById("GridView1");
after how can we get a selected row value in grid using javascript
|
|
|
|
|
 |
hi everyone can anybody help me for below functionality
i have button and grid on webform1 and i need to transfer data from gridview(seleted row) to webform2 using javascript.
|
|
|
|
 |
You can use Ajax[^]... Web Sockets[^]... LocalStorage[^] and many other options to share your data from one form to another.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
 |
i have a file,file format is CMYK(Cyan,Magenta,Yellow,Black),file have 7 layer include background,i want to multiply layer by Formula,
layer 1(cmyk)---C1,M1,M1,K1
layer 2(cmyk)---C2,M2,M2,K2
Merge all layers ways:
Layer 1 (C1, M1, Y1, K1) and layer 2 (C2, M2, Y2, K2) and Layer 3 (C3, M3, Y3, K3), ......
1.
Layer 1 and Layer 2 identical coordinate positions, with C for example
A. If C1>= C2, C = C1 + C2-2 * C1 * C2 / 100 + C1 * C1 * C2 / 10000
B. If C2 > C1, C = C1 + C2-2 * C1 * C2 / 100 + C2 * C2 * C1 / 10000
then Layer 1 and Layer 2 merged into layer 1
2.
Layer 1 and Layer 2 identical coordinate positions, with C for example
A. If C1 >= C3, C = C1 + C3-2 * C1 * C3 / 100 + C1 * C1 * C3 / 10000
B. If C3 > C1, C = C1 + C3-2 * C1 * C3 / 100 + C3 * C3 * C1 / 10000
then Layer 1 and Layer 3 merged into layer 1
3.
Layer 1 and Layer 4 identical coordinate positions, with C for example
A. If C1 >= C4, C = C1 + C4-2 * C1 * C4 / 100 + C1 * C1 * C4 / 10000
B. If C4 > C1, C = C1 + C4-2 * C1 * C4 / 100 + C4 * C4 * C1 / 10000
then Layer 1 and Layer 4 merged into layer 1
........
pls help
|
|
|
|
 |
I have a html page where I am loading PDF file using Div.
I need to refresh that Div only once without refreshing whole page using javascript or jquery.
Need urgent help.
Thanks.
|
|
|
|
 |
jQuery provides the load method[^]:
Load data from the server and place the returned HTML into the matched element.
$("#result").load("ajax/test.html");
However, you cannot display a PDF file directly within a <div> tag. You would need to use an <iframe> , or some other PDF viewer control.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
+5
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
How to make a Content Slider in JavaScript with all the function eg play, pause, replay, seek on the slider for moving back and front, sync slider with audio and contents
|
|
|
|
 |
Content slider and play pause buttons are totally different things. You are combining a media player with a content slider.
Do it yourself, using jQuery players[^], and a content slider[^].
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
 |
Then remove the jQuery from search box, and search for JavaScript version. What prevents you from doing so?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
 |
Normally JSON data is fetched in the following form from Web API etc.
[
{"name" : "Steve", "Age": 76}, {"name": "Jeremy", "Age": 43}
]
You can see that "name" and "Age" is repeating with every column. But I've seen a service getting data in this fashion. Which really shorten the JSON object something like that.
[
columns: {"name", "age"}
data: {"Steve",76},{"Jeremy",43}
]
How to do it?
|
|
|
|
 |
well, you can tweak the Json a little,
{
"name" : ["Steve", "Jeremy"],
"Age": [76,43]
}
looks greatly shortened..
|
|
|
|
 |
But you lost all the good in JSON...
I would say that compressing the traffic will do better...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
 |
Is there a good tutorial on compressing the traffic on JSON data.
|
|
|
|
|
 |
I'm trying to connect the hotel amount with the amount per day. For instance, if you select two days staying at the Economy hotel, it doubles the amount rather than doubling the amount for they the stay at the hotel alone. I've created a variable for days and added it to my if statements to retrieve the value. It was retrieving the amount for a single day correctly, but once I added that variable it began doubling everthing else.
When the user submits their form, a cost estimate for their trip should appear in an alert box with all the options: Quote: Arrival City: Use a radio button. Choices should be Omaha ($200), Nashville ($250), Detroit ($150)
Number of days as a select box with options from 2 through 6
Select box for ‘Extra Baggage ($30 each)’. Options should be ‘No Extra Bags’, ‘1 Extra Bag’, ‘2 Extra Bags’, ‘3 Extra Bags’
Have a checkbox for the following: Bringing a pet ($60)
A radio button to select the type of hotel: Economy Hotel ($140), Standard Hotel ($220), Upscale Hotel ($300)
This what I have so far.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/Javascript">
function arrivalCity ()
{
var cost = 0;
var days;
var radHotel;
days = document.reservation.selDay.value;
if (document.reservation.radCity[0].checked)
{
cost = 200;
}
if (document.reservation.radCity[1].checked )
{
cost = 250;
}
if (document.reservation.radCity[2].checked)
{
cost = 150;
}
if (document.reservation.chkYes.checked)
{
cost = cost + 60;
}
if (document.reservation.radHotel[0].checked)
{
cost = cost + 140;
}
if (document.reservation.radHotel[1].checked)
{
cost = cost + 220;
}
if (document.reservation.radHotel[2].checked)
{
cost = cost + 300;
}
if ( days == "two")
{
cost = cost * 2 ;
}
alert (cost) ;
}
</script>
</head>
<body>
<div id="header">
<form name="reservation">
<p>Where are you traveling to?
Omaha <input type ="radio" name="radCity">
Nashville <input type="radio" name="radCity">
Detroit <input type="radio" name="radCity"> </p>
<p>How many days are you staying?
<select name="selDay">
<option value="two"> 2 </option>
<option value="three"> 3 </option>
<option value"four"> 4 </option>
<option value="five"> 5 </option>
<option value="six"> 6 </option>
</select></p>
<p>Extra Baggage ($30 each):
<select name="selBag">
<option value="noBag"> No Extra Bags</option>
<option value="oneBag"> 1 Extra Bag</option>
<option value="twoBag">2 Extra Bags</option>
<option value="threeBag"> 3 Extra Bags</option>
</select> </p>
<p>Bringing a pet ($60):
Yes <input type="checkbox" name="chkYes">
No <input type="checkbox" name="chkNo">
</p>
<p>Select the name of the hotel:
Economy Hotel <input type="radio" name="radHotel" value="$140">
Standard Hotel <input type="radio" name="radHotel" value="$220">
Upscale Hotel <input type="radio" name="radHotel" value="$300">
</select></p>
<p><input type="button" value="Book My Ticket" onclick="arrivalCity ()"> </p>
</body>
</html><pre lang="Javascript">
modified 13-Mar-15 17:19pm.
|
|
|
|
 |
<head>
<!-- //In header section of the page add below url code: -->
<!-- Sesion time out and session expiry url starts here -->
<!-- Sesion time out and session expiry url starts here -->
<script type="text/javascript" language="javascript"
src="<%=request.getContextPath() %>/jsp/js/jquery.js"></script>
<script type="text/javascript">
var timeOutSesVal = 1000 * 60 * 50; // 30 min: session validation time
var timeOutSesExp = 1000 * 60 * 10; // 10 min: session expiry time
var lastActivitySesVal = new Date().getTime();
var lastActivitySesTO;
var reducingTimeSec;
var Min, Sec;
/* Sesion time out and session expiry code starts here */
//below method code is executed until showing sesion validation popup
var checkTimeout;
checkTimeOut = function() {
if (new Date().getTime() > lastActivitySesVal + timeOutSesVal) {
// document.getElementById('icwModalWashout').style.visibility = 'visible';
// document.getElementById('icwModal4').style.visibility = 'visible';
lastActivitySesTO = new Date().getTime();
checkTimeoutSesExp();// this method call is to start expiry timer and show expired message dialog
} else {
window.setTimeout(checkTimeOut, 1000 * 60 * 2); // check 10 per second
}
// }
}
//below method code is executed on click of continue button in first popup
function checkTimeOutAgain() {
lastActivitySesVal = new Date().getTime();
lastActivitySesTO = lastActivitySesVal + 1000 * 60 * 9999;//set some indefinite time to avoid showing session expiry popup
checkTimeOut();
}
//below code is for counter display
function showXMinXSec() {
reducingTimeSec = Math
.floor(((lastActivitySesTO + timeOutSesExp) - new Date()
.getTime()) / 1000);
//calculate minutes and secods
Min = Math.floor(reducingTimeSec / 60);
Sec = reducingTimeSec % 60;
if (Min > 0) {
window.confirm("your data will be lost in " + Min + " Minutes and "
+ Sec + " Seconds. Please save your data");
} else {
window.confirm("your data will be lost in " + Sec
+ " Seconds. Please save your data");
}
}
//below method code is executed for showing next/sesion expiry popup
var checkTimeoutSesExp;
checkTimeoutSesExp = function() {
if (new Date().getTime() > lastActivitySesTO + timeOutSesExp) {
//hide Session Timeout pop up/icwModal4 and enable Session expired/icwModal5 pop up after invalidating session
document.getElementById('icwModal4').style.visibility = 'hidden';
//invalidating session
// $.ajax({
// type: "POST",
// url: '',
// dataType: "json",
// success: function(){
// document.getElementById('icwModal5').style.visibility = 'visible';
// },
/* error: function(data){
alert('Error in ajax call/response!');
getElementById('icwModalWashout').style.visibility='hidden';
}*/
// });
return false;
} else {
//write logic to show X minutes and X seconds
showXMinXSec();
window.setTimeout(checkTimeoutSesExp, 1000 * 60 * 2); // check 2 min
}
}
</script>
</head>
|
|
|
|
 |
Do you have a question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
I want to make ajavascript wedget code for my website so that it can replace to another website wedget or other place for my website adverting purpose.
|
|
|
|
 |
I'd like to have unit testing for my jQuery code. Have gone through some frameworks like Qunit;Jasmine etc. Any suggestions which will be the best suited for JQuery testing automation/unit testing?
|
|
|
|
 |
we want to upload a image file and preview to page and save to folder using javascript and c# code
|
|
|
|
 |
There are examples online. Are you stuck somewhere?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
If you're talking about ajax functionality for uploading, then please read this post of mine.
Uploading the files – HTML5 and jQuery way![^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
 |
Need little help with the quiz app
I want to set time limit for each question in quiz module (say 30 seconds) and after that time, the
form will auto submit the question (auto submit = no option selected = unanswered).
There are 3 questions, so total time limit is 90 sec (30 sec each).
How to do that?
I'm doing this via XAMPP.
The link below provide the work so far
https://www.dropbox.com/s/4dzlgjtjzvs48vw/quiz.rar?dl=0
Thanks
|
|
|
|
 |
You can use the setTimeout in JavaScript to trigger a function after a time. And once the next question has been loaded, again set the timer so that after exact 30 seconds it would again submit the form.
For example, to submit the form you might run this code,
setTimeout(submitForm, 30000);
function submitForm() {
document.myForm.submit();
}
Doing the same would submit them all. You can set the timeout to re-calculate the time once the question form is loaded again. It would be simple.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
 |
can you please elaborate by putting the code in the correct place
//get total questions
$query = "SELECT * FROM `questions`";
//get result
$results = $mysqli->query($query) or die($mysqli->error.__LINE__);
$total = $results->num_rows;
//get a random question
if (empty($_SESSION['questionsUsed']))
{$questionSet = "SELECT * FROM `questions` ORDER BY RAND() LIMIT 1";}
else if ($total>count($_SESSION['questionsUsed'])) //there are more questions that haven't been asked
{
$questionsUsed = implode(',', $_SESSION['questionsUsed']);//join the array
$questionSet = "SELECT * FROM `questions` WHERE question_number not in ($questionsUsed)ORDER BY RAND() LIMIT 1";//get a random question that hasn't already been answered
}
else
{header("Location: final.php");
exit();}
$result = $mysqli->query($questionSet) or die($mysqli->error.__LINE__);
$question = $result->fetch_assoc();
//get random number
$random = $question['question_number'];
$_SESSION['questionsUsed'][] = $random;//add the question number to the list of questions asked
//get choices
$query = "SELECT * FROM `choices`
WHERE question_number = $random";
//get results
$choices = $mysqli->query($query) or die($mysqli->error.__LINE__);
?>
<html>
<head>
<meta charset="utf-8" />
<title>PHP Quizzer</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<header>
PHP Quizzer
</header>
if(isset($_SESSION['count'])){
$count = $_SESSION['count'];
}else{
$count = 0;
}
?>
Question of
<form method="post" action="process.php">
fetch_assoc()) : ?>
- <input name="choice" type="radio" value="" />
<input type="submit" value="Submit" />
<input type="hidden" name="number" value="" />
</form>
</body>
</html>
|
|
|
|
 |
Hi All,
I have an Unordered List which has many list items, and when we select a li, it opens up two spans, in one of the Span we have have radio buttons, I want to get the baseURL field that is attached to the li that I am selecting so that, can any one please help me any code snippet, link or even suggestion would be helpful. Thanks in advance.
All I want is either to get the report-url attribute or value of the span under the li that is selected or we can say active, I tried in the following ways but couldn't succeed, by the way I have to get these values when I click on the radio button that is within this list item, please help me.
var listitm = $("#li.report active");
var ttl = listitm.find('span.title').toString();
alert(ttl);
<li class="report active">
<span class="title" report-url="/ELMS/Reports/Definitions/EnrollmentByChild.rdl">Enrollment by Child</span>
<span class="description">
Lists children with their age, poverty level, IEP status, priority points and first and last days attending class.
This report includes children who have started class and children with an expected start date in the future. The "As of" date version of this report includes children with a pending exit or with an exit on the "As Of" date. The "Cumulative" version of this report includes all children who exited during the reporting period. Children who never attend class are subtracted from this report upon exit or transfer.</span>
<div id="report-parameters" style="position: relative; background-color: rgb(255, 255, 255);">
<div id="parameterList" class="my-container form report-parameters">
<div id="phb_valSummary" class="ValidationSummary" style="display:none;">
</div>
<div id="phb_happySummary" class="SuccessSummary" style="display:none;">
<div class="close" title="Close the saved successfully notification.">x</div>
</div>
<div id="phb_warnSummary" class="WarningSummary" style="display:none;">
</div>
<h2>Report Parameters for Enrollment by Child Report</h2>
<div id="phb_pnlParam_SchoolYear" class="my-section col divider">
<label for="phb_ddlSchoolYear" id="phb_lblSchoolYear" class="req">School Year</label>
</div>
<div class="my-section action-buttons">
<input type="submit" name="ctl00$phb$btnRunReport1" value="Run Report" id="phb_btnRunReport1" style="width: 115px; background-image: url(http://localhost/ELMS/Reports/Image.axd?t=Run+Report&r=0&g=178&b=214&p=20&h=25); background-color: transparent;" />
</div>
</div>
<span style="position: absolute; top: 5px; right: 20px; cursor: pointer;">- Hide Parameters</span>
</div>
</li>
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
modified 24-Feb-15 12:20pm.
|
|
|
|
 |
This line:
var listitm = $("#li.report active");
You're referencing "active" as if it's a tag. Add the "." before it, like so: "#li.report.active". You can chain the tag + classes.
Also, to read an attribute, you use jQuery's "attr()" method:
var title = listitm.find("span.title").text(); var url = listitm.find("span.title").attr("report-url");
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|