Hi,
I'm not massively experienced with JS, but have some experience with php so can read the code reasonably well.
I'm looking to make both fields on my html form required, just a simple alert window would do the trick. I've tried a few simple examples, but they don't seem to work with my form, I think it's because I have a little JS in the form itself, which could be conflicting.
Here is my form:
I would like both fields to be required, like a say, a little alert would be just fine.Code:<form id="two" action=" " name=form method="post"> <input name="email" id="email" type="text" value="E-Mail" onfocus="this.value=(this.value=='E-Mail') ? '' : this.value;" onblur="this.value=(this.value=='') ? 'E-Mail' : this.value;"> <input name="city" id="city" type="text" value="City" onfocus="this.value=(this.value=='City') ? '' : this.value;" onblur="this.value=(this.value=='') ? 'City' : this.value;"> <input id="button" type="submit" value="Get Free Track"> </form>
The sources I read and tried (unsuccessfully) were:
JavaScript Tip: Basic Form Validation With JavaScript
The JavaScript Source: Forms: Required Fields
Use JavaScript to Check Required HTML Form Fields
Could anyone point me in the right direction?
Thanks,
James


LinkBack URL
About LinkBacks






Reply With Quote