it's not giving me error message when I input different pattern, what did I do wrong ?
<label for="receipt">Receipt number *</label>
<input name="receipt" id="receipt"
placeholder="re-nnnnnn" required="required"
pattern="^re\-\d{6}$" />
It depends on what you want to achieve. For example, if your goal is re-123456, you should remove the first back-slash.
<form action="">
<label for="receipt">Receipt number *</label>
<input name="receipt" id="receipt" placeholder="re-nnnnnn" required="required" pattern="^re-\d{6}$" />
</form>
I tried looking up at the issue but, it seems like I am doing it right?
So my HTML content shows that
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" [(ngModel)]="email" required>
<label for="username"><b>User Name</b></label>
<input type="text" placeholder="User Name" [(ngModel)]="username" required>
<label for="firstname"><b>First Name</b></label>
<input type="text" placeholder="Enter First Name" [(ngModel)]="firstname" required>
<label for="lastname"><b>Last Name</b></label>
<input type="text" placeholder="Enter Last Name" [(ngModel)]="lastname" required>
I have errors running through my HTML
Error occurs in the template of component SignupComponent.
and each of them says
Property 'lastname' does not exist on type 'SignupComponent'.
I have some required fields in my html code, but they do not show the place holder until I specify that the field is required. I do not know why...
<input class="text" type="password" name="password" placeholder="Enter new password" required="">
<br>
<input class="text" type="text" name="phone" placeholder="Enter new phone number">
The second input does not show the place holder when I run the code.
<form class="form-asd" role="form">
<h2 class="form-signin-heading">login</h2><hr />
<label class="control-label" for="username">Username</label>
<input class="form-control" type="email" required="" placeholder="username"data-error="enter username"></input>
<label class="control-label" for="username">password</label>
<input class="form-control" type="password" required=" " placeholder="Password"></input>
<label class="checkbox"></label>
<button class="btn btn-lg btn-primary " type="submit">submit</button>
</form>
how can we change this default message of popover of the require field "Please fill out this field "to "please enter username"
You can use setCustomValidity function when oninvalid event occurs.
Like below:-
<input class="form-control" type="email" required=""
placeholder="username" oninvalid="this.setCustomValidity('Please Enter valid email')">
</input>
Update:-
To clear the message once you start entering use oninput="setCustomValidity('') attribute to clear the message.
<input class="form-control" type="email" required="" placeholder="username"
oninvalid="this.setCustomValidity('Please Enter valid email')"
oninput="setCustomValidity('')"></input>
Combination of Mritunjay and Bartu's answers are full answer to this question. I copying the full example.
<input class="form-control" type="email" required="" placeholder="username"
oninvalid="this.setCustomValidity('Please Enter valid email')"
oninput="setCustomValidity('')"></input>
Here,
this.setCustomValidity('Please Enter valid email')" - Display the custom message on invalidated of the field
oninput="setCustomValidity('')" - Remove the invalidate message on validated filed.
And for all input and select:
$("input[required], select[required]").attr("oninvalid", "this.setCustomValidity('Required!')");
$("input[required], select[required]").attr("oninput", "setCustomValidity('')");
I wanted to change the text of the textarea. This method helped
<form action="/action_page.php" method="post">
<input type="text" required placeholder="username" oninvalid="this.setCustomValidity('Error validate')" oninput="setCustomValidity('')">
<br><br>
<textarea placeholder="Ko’cha, uy, xonadon" name="address" required oninvalid="this.setCustomValidity('Majburiy maydon')" oninput="setCustomValidity('')"></textarea>
<input type="submit" value="Submit">
</form>
$("input[required]").attr("oninvalid", "this.setCustomValidity('Say Somthing!')");
this work if you move to previous or next field by mouse, but by enter key, this is not work !!!
I am new to php and would like some help on solving a problem I am having. I have a form that has 3 visible input fields, Name, Email address, phone number. Also it includes 3 hidden fields, one is a value set to 2500, the second is a currency, the third needs to be a unique ID. I need help on how to generate a unique id and pass the text/value into a input field in another form. Below is my code. I need the random id to be displayed on the input field merchantid. Thanks
<form action="https:urlthathastheform" method="post">
<input type="hidden" id="merchantid" name="merchantid" />
<input type="hidden" id="currency" name="currency" value="$" />
<label for="names">Names</label>
<input type="text" name="names" id="names" />
<label for="email_address">Email Address</label>
<input type="text" name="email_address" id="email_address" />
<label for="phone_number">Phone Number</label>
<input type="text" name="phone_number" id="phone_number" />
<label for="amount">Amount</label>
<input type="text" name="amount" value="2500" />
<input type="submit" name="submit" value="submit" />
</form>
php has a function to generate a unique id.
<input type="hidden" id="merchantid" name="merchantid" value="<?php echo uniqid();>"/>
Note, this id is based on the system clock. http://php.net/manual/en/function.uniqid.php